LibreOffice
LibreOffice 6.4 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 <utility>
30 #include <string.h>
31 
32 #if defined LIBO_INTERNAL_ONLY
33 #include <string_view>
34 #endif
35 
36 #include "rtl/textenc.h"
37 #include "rtl/string.h"
38 #include "rtl/stringutils.hxx"
39 
40 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
41 #include "rtl/stringconcat.hxx"
42 #endif
43 
44 #ifdef RTL_STRING_UNITTEST
45 extern bool rtl_string_unittest_const_literal;
46 extern bool rtl_string_unittest_const_literal_function;
47 #endif
48 
49 // The unittest uses slightly different code to help check that the proper
50 // calls are made. The class is put into a different namespace to make
51 // sure the compiler generates a different (if generating also non-inline)
52 // copy of the function and does not merge them together. The class
53 // is "brought" into the proper rtl namespace by a typedef below.
54 #ifdef RTL_STRING_UNITTEST
55 #define rtl rtlunittest
56 #endif
57 
58 namespace rtl
59 {
60 
62 #ifdef RTL_STRING_UNITTEST
63 #undef rtl
64 // helper macro to make functions appear more readable
65 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
66 #else
67 #define RTL_STRING_CONST_FUNCTION
68 #endif
69 
71 /* ======================================================================= */
72 
97 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
98 {
99 public:
101  rtl_String * pData;
103 
108  {
109  pData = NULL;
110  rtl_string_new( &pData );
111  }
112 
118  OString( const OString & str )
119  {
120  pData = str.pData;
121  rtl_string_acquire( pData );
122  }
123 
124 #ifndef _MSC_VER // TODO?
125 #if defined LIBO_INTERNAL_ONLY
126 
132  OString( OString && str ) noexcept
133  {
134  pData = str.pData;
135  str.pData = nullptr;
136  rtl_string_new( &str.pData );
137  }
138 #endif
139 #endif
140 
146  OString( rtl_String * str )
147  {
148  pData = str;
149  rtl_string_acquire( pData );
150  }
151 
159  OString( rtl_String * str, __sal_NoAcquire )
160  {
161  pData = str;
162  }
163 
169  explicit OString( sal_Char value )
170  : pData (NULL)
171  {
172  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
173  }
174 
183  template< typename T >
185  {
186  pData = NULL;
187  rtl_string_newFromStr( &pData, value );
188  }
189 
190  template< typename T >
192  {
193  pData = NULL;
194  rtl_string_newFromStr( &pData, value );
195  }
196 
207  template< typename T >
209  {
210  assert(
212  pData = NULL;
214  rtl_string_new(&pData);
215  } else {
217  &pData,
219  literal),
221  }
222 #ifdef RTL_STRING_UNITTEST
223  rtl_string_unittest_const_literal = true;
224 #endif
225  }
226 
235  OString( const sal_Char * value, sal_Int32 length )
236  {
237  pData = NULL;
238  rtl_string_newFromStr_WithLength( &pData, value, length );
239  }
240 
255  OString( const sal_Unicode * value, sal_Int32 length,
256  rtl_TextEncoding encoding,
257  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
258  {
259  pData = NULL;
260  rtl_uString2String( &pData, value, length, encoding, convertFlags );
261  if (pData == NULL) {
262  throw std::bad_alloc();
263  }
264  }
265 
266 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
267 
271  template< typename T1, typename T2 >
272  OString( OStringConcat< T1, T2 >&& c )
273  {
274  const sal_Int32 l = c.length();
275  pData = rtl_string_alloc( l );
276  if (l != 0)
277  {
278  char* end = c.addData( pData->buffer );
279  pData->length = l;
280  *end = '\0';
281  }
282  }
283 
288  template< typename T >
289  OString( OStringNumber< T >&& n )
290  : OString( n.buf, n.length )
291  {}
292 #endif
293 
294 #ifdef LIBO_INTERNAL_ONLY
295  OString(std::nullptr_t) = delete;
296 #endif
297 
302  {
303  rtl_string_release( pData );
304  }
305 
311  OString & operator=( const OString & str )
312  {
313  rtl_string_assign( &pData, str.pData );
314  return *this;
315  }
316 
317 #ifndef _MSC_VER // TODO?
318 #if defined LIBO_INTERNAL_ONLY
319 
325  OString & operator=( OString && str ) noexcept
326  {
327  rtl_string_release( pData );
328  pData = str.pData;
329  str.pData = nullptr;
330  rtl_string_new( &str.pData );
331  return *this;
332  }
333 #endif
334 #endif
335 
341  template< typename T >
343  {
344  RTL_STRING_CONST_FUNCTION
345  assert(
348  rtl_string_new(&pData);
349  } else {
351  &pData,
353  literal),
355  }
356  return *this;
357  }
358 
364  OString & operator+=( const OString & str )
365 #if defined LIBO_INTERNAL_ONLY
366  &
367 #endif
368  {
369  rtl_string_newConcat( &pData, pData, str.pData );
370  return *this;
371  }
372 #if defined LIBO_INTERNAL_ONLY
373  void operator+=(OString const &) && = delete;
374 #endif
375 
376 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
377 
381  template< typename T1, typename T2 >
382  OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
383  sal_Int32 l = c.length();
384  if( l == 0 )
385  return *this;
386  l += pData->length;
387  rtl_string_ensureCapacity( &pData, l );
388  char* end = c.addData( pData->buffer + pData->length );
389  *end = '\0';
390  pData->length = l;
391  return *this;
392  }
393  template<typename T1, typename T2> void operator +=(
394  OStringConcat<T1, T2> &&) && = delete;
395 
400  template< typename T >
401  OString& operator+=( OStringNumber< T >&& n ) & {
402  sal_Int32 l = n.length;
403  if( l == 0 )
404  return *this;
405  l += pData->length;
406  rtl_string_ensureCapacity( &pData, l );
407  char* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
408  *end = '\0';
409  pData->length = l;
410  return *this;
411  }
412  template<typename T> void operator +=(
413  OStringNumber<T> &&) && = delete;
414 #endif
415 
420  void clear()
421  {
422  rtl_string_new( &pData );
423  }
424 
433  sal_Int32 getLength() const { return pData->length; }
434 
443  bool isEmpty() const
444  {
445  return pData->length == 0;
446  }
447 
459  const sal_Char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
460 
470  sal_Char operator [](sal_Int32 index) const {
471  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
472  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
473  return getStr()[index];
474  }
475 
488  sal_Int32 compareTo( const OString & str ) const
489  {
490  return rtl_str_compare_WithLength( pData->buffer, pData->length,
491  str.pData->buffer, str.pData->length );
492  }
493 
507  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
508  {
509  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
510  rObj.pData->buffer, rObj.pData->length, maxLength );
511  }
512 
525  sal_Int32 reverseCompareTo( const OString & str ) const
526  {
527  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
528  str.pData->buffer, str.pData->length );
529  }
530 
542  bool equals( const OString & str ) const
543  {
544  if ( pData->length != str.pData->length )
545  return false;
546  if ( pData == str.pData )
547  return true;
548  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
549  str.pData->buffer, str.pData->length ) == 0;
550  }
551 
567  bool equalsL( const sal_Char* value, sal_Int32 length ) const
568  {
569  if ( pData->length != length )
570  return false;
571 
572  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
573  value, length ) == 0;
574  }
575 
590  bool equalsIgnoreAsciiCase( const OString & str ) const
591  {
592  if ( pData->length != str.pData->length )
593  return false;
594  if ( pData == str.pData )
595  return true;
596  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
597  str.pData->buffer, str.pData->length ) == 0;
598  }
599 
621  template< typename T >
623  {
624  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
625  }
626 
627  template< typename T >
629  {
630  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
631  }
632 
638  template< typename T >
640  {
641  RTL_STRING_CONST_FUNCTION
642  assert(
644  return
645  (pData->length
648  pData->buffer, pData->length,
650  literal),
652  == 0);
653  }
654 
674  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
675  {
676  if ( pData->length != asciiStrLength )
677  return false;
678 
679  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
680  asciiStr, asciiStrLength ) == 0;
681  }
682 
698  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
699  {
700  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
701  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
702  }
703 
709  template< typename T >
710  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
711  {
712  RTL_STRING_CONST_FUNCTION
713  assert(
715  return
717  pData->buffer + fromIndex, pData->length - fromIndex,
719  literal),
722  == 0;
723  }
724 
741  bool matchL(
742  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
743  const
744  {
746  pData->buffer + fromIndex, pData->length - fromIndex,
747  str, strLength, strLength) == 0;
748  }
749 
750  // This overload is left undefined, to detect calls of matchL that
751  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
752  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
753  // platforms):
754 #if SAL_TYPES_SIZEOFLONG == 8
755  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
756 #endif
757 
776  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
777  {
778  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
779  str.pData->buffer, str.pData->length,
780  str.pData->length ) == 0;
781  }
782 
788  template< typename T >
789  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
790  {
791  RTL_STRING_CONST_FUNCTION
792  assert(
794  return
796  pData->buffer+fromIndex, pData->length-fromIndex,
798  literal),
801  == 0;
802  }
803 
818  bool startsWith(OString const & str, OString * rest = NULL) const {
819  bool b = match(str);
820  if (b && rest != NULL) {
821  *rest = copy(str.getLength());
822  }
823  return b;
824  }
825 
831  template< typename T >
833  T & literal, OString * rest = NULL) const
834  {
835  RTL_STRING_CONST_FUNCTION
836  bool b = match(literal, 0);
837  if (b && rest != NULL) {
838  *rest = copy(
840  }
841  return b;
842  }
843 
863  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
864  const
865  {
866  bool b = matchIgnoreAsciiCase(str);
867  if (b && rest != NULL) {
868  *rest = copy(str.getLength());
869  }
870  return b;
871  }
872 
878  template< typename T >
880  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
881  {
882  RTL_STRING_CONST_FUNCTION
883  assert(
885  bool b = matchIgnoreAsciiCase(literal);
886  if (b && rest != NULL) {
887  *rest = copy(
889  }
890  return b;
891  }
892 
907  bool endsWith(OString const & str, OString * rest = NULL) const {
908  bool b = str.getLength() <= getLength()
909  && match(str, getLength() - str.getLength());
910  if (b && rest != NULL) {
911  *rest = copy(0, getLength() - str.getLength());
912  }
913  return b;
914  }
915 
921  template< typename T >
923  T & literal, OString * rest = NULL) const
924  {
925  RTL_STRING_CONST_FUNCTION
926  assert(
928  bool b
930  <= sal_uInt32(getLength()))
931  && match(
933  literal),
934  (getLength()
936  if (b && rest != NULL) {
937  *rest = copy(
938  0,
939  (getLength()
941  }
942  return b;
943  }
944 
958  bool endsWithL(char const * str, sal_Int32 strLength) const {
959  return strLength <= getLength()
960  && matchL(str, strLength, getLength() - strLength);
961  }
962 
963  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
964  { return rStr1.equals(rStr2); }
965  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
966  { return !(operator == ( rStr1, rStr2 )); }
967  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
968  { return rStr1.compareTo( rStr2 ) < 0; }
969  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
970  { return rStr1.compareTo( rStr2 ) > 0; }
971  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
972  { return rStr1.compareTo( rStr2 ) <= 0; }
973  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
974  { return rStr1.compareTo( rStr2 ) >= 0; }
975 
976  template< typename T >
977  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
978  {
979  return rStr1.compareTo( value ) == 0;
980  }
981 
982  template< typename T >
984  {
985  return rStr1.compareTo( value ) == 0;
986  }
987 
988  template< typename T >
989  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
990  {
991  return rStr2.compareTo( value ) == 0;
992  }
993 
994  template< typename T >
996  {
997  return rStr2.compareTo( value ) == 0;
998  }
999 
1005  template< typename T >
1007  {
1008  RTL_STRING_CONST_FUNCTION
1009  assert(
1011  return
1012  (rStr.getLength()
1015  rStr.pData->buffer, rStr.pData->length,
1017  literal),
1019  == 0);
1020  }
1021 
1027  template< typename T >
1029  {
1030  RTL_STRING_CONST_FUNCTION
1031  assert(
1033  return
1034  (rStr.getLength()
1037  rStr.pData->buffer, rStr.pData->length,
1039  literal),
1041  == 0);
1042  }
1043 
1044  template< typename T >
1045  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1046  {
1047  return !(operator == ( rStr1, value ));
1048  }
1049 
1050  template< typename T >
1052  {
1053  return !(operator == ( rStr1, value ));
1054  }
1055 
1056  template< typename T >
1057  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1058  {
1059  return !(operator == ( value, rStr2 ));
1060  }
1061 
1062  template< typename T >
1064  {
1065  return !(operator == ( value, rStr2 ));
1066  }
1067 
1073  template< typename T >
1075  {
1076  return !( rStr == literal );
1077  }
1078 
1084  template< typename T >
1086  {
1087  return !( literal == rStr );
1088  }
1089 
1097  sal_Int32 hashCode() const
1098  {
1099  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1100  }
1101 
1115  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1116  {
1117  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1118  return (ret < 0 ? ret : ret+fromIndex);
1119  }
1120 
1130  sal_Int32 lastIndexOf( sal_Char ch ) const
1131  {
1132  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1133  }
1134 
1147  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1148  {
1149  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1150  }
1151 
1167  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1168  {
1169  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1170  str.pData->buffer, str.pData->length );
1171  return (ret < 0 ? ret : ret+fromIndex);
1172  }
1173 
1179  template< typename T >
1180  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1181  {
1182  RTL_STRING_CONST_FUNCTION
1183  assert(
1185  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1186  pData->buffer + fromIndex, pData->length - fromIndex,
1189  return n < 0 ? n : n + fromIndex;
1190  }
1191 
1210  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1211  const
1212  {
1213  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1214  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1215  return n < 0 ? n : n + fromIndex;
1216  }
1217 
1218  // This overload is left undefined, to detect calls of indexOfL that
1219  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1220  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1221  // platforms):
1222 #if SAL_TYPES_SIZEOFLONG == 8
1223  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1224 #endif
1225 
1241  sal_Int32 lastIndexOf( const OString & str ) const
1242  {
1243  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1244  str.pData->buffer, str.pData->length );
1245  }
1246 
1264  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1265  {
1266  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1267  str.pData->buffer, str.pData->length );
1268  }
1269 
1280  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1281  {
1282  return copy(beginIndex, getLength() - beginIndex);
1283  }
1284 
1297  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1298  {
1299  rtl_String *pNew = NULL;
1300  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1301  return OString( pNew, SAL_NO_ACQUIRE );
1302  }
1303 
1313  {
1314  rtl_String* pNew = NULL;
1315  rtl_string_newConcat( &pNew, pData, str.pData );
1316  return OString( pNew, SAL_NO_ACQUIRE );
1317  }
1318 
1319 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1320  friend OString operator+( const OString & str1, const OString & str2 )
1321  {
1322  return str1.concat( str2 );
1323  }
1324 #endif
1325 
1339  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1340  {
1341  rtl_String* pNew = NULL;
1342  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1343  return OString( pNew, SAL_NO_ACQUIRE );
1344  }
1345 
1360  {
1361  rtl_String* pNew = NULL;
1362  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1363  return OString( pNew, SAL_NO_ACQUIRE );
1364  }
1365 
1385  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1386  {
1387  rtl_String * s = NULL;
1388  sal_Int32 i = 0;
1390  &s, pData, from.pData->buffer, from.pData->length,
1391  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1392  return OString(s, SAL_NO_ACQUIRE);
1393  }
1394 
1408  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1409  rtl_String * s = NULL;
1411  &s, pData, from.pData->buffer, from.pData->length,
1412  to.pData->buffer, to.pData->length);
1413  return OString(s, SAL_NO_ACQUIRE);
1414  }
1415 
1427  {
1428  rtl_String* pNew = NULL;
1429  rtl_string_newToAsciiLowerCase( &pNew, pData );
1430  return OString( pNew, SAL_NO_ACQUIRE );
1431  }
1432 
1444  {
1445  rtl_String* pNew = NULL;
1446  rtl_string_newToAsciiUpperCase( &pNew, pData );
1447  return OString( pNew, SAL_NO_ACQUIRE );
1448  }
1449 
1462  {
1463  rtl_String* pNew = NULL;
1464  rtl_string_newTrim( &pNew, pData );
1465  return OString( pNew, SAL_NO_ACQUIRE );
1466  }
1467 
1492  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1493  {
1494  rtl_String * pNew = NULL;
1495  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1496  return OString( pNew, SAL_NO_ACQUIRE );
1497  }
1498 
1512  OString getToken(sal_Int32 count, char separator) const {
1513  sal_Int32 n = 0;
1514  return getToken(count, separator, n);
1515  }
1516 
1525  bool toBoolean() const
1526  {
1527  return rtl_str_toBoolean( pData->buffer );
1528  }
1529 
1537  {
1538  return pData->buffer[0];
1539  }
1540 
1551  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1552  {
1553  return rtl_str_toInt32( pData->buffer, radix );
1554  }
1555 
1568  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1569  {
1570  return rtl_str_toUInt32( pData->buffer, radix );
1571  }
1572 
1583  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1584  {
1585  return rtl_str_toInt64( pData->buffer, radix );
1586  }
1587 
1600  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1601  {
1602  return rtl_str_toUInt64( pData->buffer, radix );
1603  }
1604 
1613  float toFloat() const
1614  {
1615  return rtl_str_toFloat( pData->buffer );
1616  }
1617 
1626  double toDouble() const
1627  {
1628  return rtl_str_toDouble( pData->buffer );
1629  }
1630 
1631 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1632 
1633  static OStringNumber< int > number( int i, sal_Int16 radix = 10 )
1634  {
1635  return OStringNumber< int >( i, radix );
1636  }
1637  static OStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
1638  {
1639  return OStringNumber< long long >( ll, radix );
1640  }
1641  static OStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
1642  {
1643  return OStringNumber< unsigned long long >( ll, radix );
1644  }
1645  static OStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
1646  {
1647  return number( static_cast< unsigned long long >( i ), radix );
1648  }
1649  static OStringNumber< long long > number( long i, sal_Int16 radix = 10)
1650  {
1651  return number( static_cast< long long >( i ), radix );
1652  }
1653  static OStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
1654  {
1655  return number( static_cast< unsigned long long >( i ), radix );
1656  }
1657  static OStringNumber< float > number( float f )
1658  {
1659  return OStringNumber< float >( f );
1660  }
1661  static OStringNumber< double > number( double d )
1662  {
1663  return OStringNumber< double >( d );
1664  }
1665 #else
1666 
1676  static OString number( int i, sal_Int16 radix = 10 )
1677  {
1679  return OString(aBuf, rtl_str_valueOfInt32(aBuf, i, radix));
1680  }
1683  static OString number( unsigned int i, sal_Int16 radix = 10 )
1684  {
1685  return number( static_cast< unsigned long long >( i ), radix );
1686  }
1689  static OString number( long i, sal_Int16 radix = 10 )
1690  {
1691  return number( static_cast< long long >( i ), radix );
1692  }
1695  static OString number( unsigned long i, sal_Int16 radix = 10 )
1696  {
1697  return number( static_cast< unsigned long long >( i ), radix );
1698  }
1701  static OString number( long long ll, sal_Int16 radix = 10 )
1702  {
1704  return OString(aBuf, rtl_str_valueOfInt64(aBuf, ll, radix));
1705  }
1708  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1709  {
1711  return OString(aBuf, rtl_str_valueOfUInt64(aBuf, ll, radix));
1712  }
1713 
1723  static OString number( float f )
1724  {
1726  return OString(aBuf, rtl_str_valueOfFloat(aBuf, f));
1727  }
1728 
1738  static OString number( double d )
1739  {
1741  return OString(aBuf, rtl_str_valueOfDouble(aBuf, d));
1742  }
1743 #endif
1744 
1756  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1757  {
1758  return boolean(b);
1759  }
1760 
1772  static OString boolean( bool b )
1773  {
1775  return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
1776  }
1777 
1785  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1786  {
1787  return OString( &c, 1 );
1788  }
1789 
1800  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1801  {
1802  return number( i, radix );
1803  }
1804 
1815  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1816  {
1817  return number( ll, radix );
1818  }
1819 
1829  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1830  {
1831  return number(f);
1832  }
1833 
1843  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1844  {
1845  return number(d);
1846  }
1847 
1848 #if defined LIBO_INTERNAL_ONLY
1849  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
1850 #endif
1851 };
1852 
1853 /* ======================================================================= */
1854 
1855 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1856 
1864 struct SAL_WARN_UNUSED OStringLiteral
1865 {
1866  template< int N >
1867  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1868 #if defined __cpp_char8_t
1869  template< int N >
1870  explicit OStringLiteral( const char8_t (&str)[ N ] ) : size( N - 1 ), data( reinterpret_cast<char const *>(str) ) { assert( strlen( data ) == N - 1 ); }
1871 #endif
1872  int size;
1873  const char* data;
1874 };
1875 
1879 template<>
1880 struct ToStringHelper< OString >
1881  {
1882  static std::size_t length( const OString& s ) { return s.getLength(); }
1883  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1884  static const bool allowOStringConcat = true;
1885  static const bool allowOUStringConcat = false;
1886  };
1887 
1891 template<>
1892 struct ToStringHelper< OStringLiteral >
1893  {
1894  static std::size_t length( const OStringLiteral& str ) { return str.size; }
1895  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1896  static const bool allowOStringConcat = true;
1897  static const bool allowOUStringConcat = false;
1898  };
1899 
1903 template< typename charT, typename traits, typename T1, typename T2 >
1904 inline std::basic_ostream<charT, traits> & operator <<(
1905  std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
1906 {
1907  return stream << OString( std::move(concat) );
1908 }
1909 #endif
1910 
1911 
1918 {
1928  size_t operator()( const OString& rString ) const
1929  { return static_cast<size_t>(rString.hashCode()); }
1930 };
1931 
1934 {
1935  bool operator()( const char* p1, const char* p2) const
1936  { return rtl_str_compare(p1, p2) == 0; }
1937 };
1938 
1941 {
1942  size_t operator()(const char* p) const
1943  { return rtl_str_hashCode(p); }
1944 };
1945 
1946 /* ======================================================================= */
1947 
1954 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1955 operator <<(
1956  std::basic_ostream<charT, traits> & stream, OString const & rString)
1957 {
1958  return stream << rString.getStr();
1959  // best effort; potentially loses data due to embedded null characters
1960 }
1961 
1962 } /* Namespace */
1963 
1964 #ifdef RTL_STRING_UNITTEST
1965 namespace rtl
1966 {
1967 typedef rtlunittest::OString OString;
1968 }
1969 #undef RTL_STRING_CONST_FUNCTION
1970 #endif
1971 
1972 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1973 using ::rtl::OString;
1974 using ::rtl::OStringChar;
1975 using ::rtl::OStringHash;
1976 using ::rtl::OStringLiteral;
1977 #endif
1978 
1980 
1985 #if defined LIBO_INTERNAL_ONLY
1986 namespace std {
1987 
1988 template<>
1989 struct hash<::rtl::OString>
1990 {
1991  std::size_t operator()(::rtl::OString const & s) const
1992  { return std::size_t(s.hashCode()); }
1993 };
1994 
1995 }
1996 
1997 #endif
1998 
2000 #endif // INCLUDED_RTL_STRING_HXX
2001 
2002 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OString::operator+=
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:364
rtl_string_newToAsciiUpperCase
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.
rtl_string_alloc
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:120
rtl_str_toUInt64
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.
salhelper::operator>
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
rtl::OString::operator==
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:983
rtl::OString::OString
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:208
rtl::OString::operator+
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1320
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:133
rtl::CStringEqual
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1934
rtl::OString::OString
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:255
rtl_str_lastIndexOfChar_WithLength
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.
rtl::OString::endsWith
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:907
rtl::CStringHash::operator()
size_t operator()(const char *p) const
Definition: string.hxx:1942
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
rtl::OString::number
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1738
rtl::OString::operator==
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:1028
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1241
rtl::OString::operator==
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:977
rtl_str_shortenedCompare_WithLength
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.
rtl_string_ensureCapacity
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.
rtl::OString::OString
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:146
rtl::OString::reverseCompareTo
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:525
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:374
textenc.h
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:98
rtl_string_acquire
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
rtl_string_newReplaceAll
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.
string.h
rtl::OString::toBoolean
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1525
salhelper::operator<
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
rtl::OString::operator!=
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1051
rtl::OString::OString
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:169
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
rtl_string_assign
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
rtl_str_reverseCompare_WithLength
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.
rtl::OString::endsWith
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:922
RTL_STR_MAX_VALUEOFUINT64
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
rtl::OString::OString
OString()
New string containing no characters.
Definition: string.hxx:107
rtl_str_indexOfChar_WithLength
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.
rtl_string_newReplaceStrAt
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.
rtl_str_hashCode_WithLength
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.
rtl_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl::OString::number
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:1701
rtl::OString::startsWithIgnoreAsciiCase
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:863
rtl_string_newToAsciiLowerCase
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.
rtl::OString::endsWithL
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:958
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:628
rtl_str_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(sal_Char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl::OString::operator!=
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:1085
rtl::OString::startsWith
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:832
rtl::OString::operator==
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:995
rtl::OString::equalsIgnoreAsciiCase
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:639
OUSTRING_TO_OSTRING_CVTFLAGS
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
rtl::OString::match
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:698
rtl_str_valueOfInt64
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.
rtl::OString::operator!=
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1045
rtl::OString::getToken
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1512
rtl_str_compareIgnoreAsciiCase_WithLength
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.
rtl_str_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl::OString::toInt64
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1583
rtl::OString::toUInt32
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1568
rtl::OString::replace
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:1359
com::sun::star::uno::operator!=
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:664
rtl_str_lastIndexOfStr_WithLength
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.
rtl_uString2String
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.
rtl::OString::~OString
~OString()
Release the string data.
Definition: string.hxx:301
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
rtl::OStringHash::operator()
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1928
rtl::OString::number
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:1695
rtl::OString::equals
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:542
config.h
rtl::OString::concat
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1312
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
rtl::OString::OString
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:184
rtl::OString::toAsciiLowerCase
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:1426
rtl_str_compare_WithLength
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.
rtl_string_newFromSubString
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.
rtl::OString::number
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:1708
rtl::OString::copy
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:1297
rtl::OString::equalsL
bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:567
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
rtl_string_newFromStr_WithLength
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.
rtl::OString::indexOf
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,...
Definition: string.hxx:1115
rtl_str_toUInt32
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.
rtl_string_newReplaceFirst
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.
rtl_str_valueOfUInt64
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.
rtl::OString::boolean
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1772
rtl_string_newTrim
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.
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1147
rtl::OString::replaceAt
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:1339
rtl
Definition: bootstrap.hxx:30
rtl::OString::number
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:1683
rtl_str_hashCode
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const sal_Char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
rtl::OString::operator!=
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:1074
rtl::OString::clear
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:420
rtl::OString::trim
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:1461
rtl::OString::toFloat
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1613
rtl::OString::compareTo
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:488
rtl::OString::number
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:1689
rtl_string_newFromStr
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.
rtl_str_compareIgnoreAsciiCase
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.
rtl_str_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:371
rtl::OString::operator==
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:1006
rtl::OString::indexOf
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,...
Definition: string.hxx:1167
rtl_str_toBoolean
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
rtl_str_indexOfStr_WithLength
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.
rtl::OString::toChar
sal_Char toChar() const
Returns the first character from this string.
Definition: string.hxx:1536
rtl::OString::matchL
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:741
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:465
rtl::OString::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:459
rtl::CStringEqual::operator()
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1935
rtl::OString::number
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1676
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1130
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:130
rtl::OString::toUInt64
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1600
rtl::OString::copy
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1280
rtl::OStringHash
A helper to use OStrings with hash maps.
Definition: string.hxx:1918
rtl::OString::equalsIgnoreAsciiCaseL
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:674
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:185
rtl::OString::startsWithIgnoreAsciiCase
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:880
SAL_WARN_UNUSED_RESULT
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
rtl::OString::toDouble
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1626
rtl::OString::indexOfL
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,...
Definition: string.hxx:1210
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:433
rtl::OString::matchIgnoreAsciiCase
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:776
rtl_string_getToken
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.
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength
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.
rtl_str_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
RTL_STR_MAX_VALUEOFINT32
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:141
rtl_str_compare
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:622
rtl::OString::OString
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:159
rtl::OString::replaceFirst
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:1384
rtl_str_toFloat
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
salhelper::operator==
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
rtl::OString::getToken
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1492
rtl::OString::operator!=
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1057
rtl::OString::hashCode
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1097
rtl::OString::compareTo
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:507
rtl::OString::toAsciiUpperCase
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:1443
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.hxx:157
rtl::OString::OString
OString(const OString &str)
New string from OString.
Definition: string.hxx:118
rtl::OString::matchIgnoreAsciiCase
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:789
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1264
rtl_str_toInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
rtl_str_toInt64
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.
rtl_string_newFromLiteral
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
rtl::operator<<
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,...
Definition: string.hxx:1955
rtl_string_newReplace
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.
rtl::OString::operator==
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:989
rtl::OString::OString
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:235
rtl::OString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:443
rtl::OString::equalsIgnoreAsciiCase
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:590
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
rtl::OString::number
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1723
rtl::CStringHash
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1941
rtl::OString::OString
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:191
rtl::OString::operator=
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:342
rtl_string_newConcat
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.
rtl::OString::replaceAll
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:1408
rtl::OString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1551
rtl::OString::indexOf
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:1180
rtl::OString::operator!=
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1063
rtl::OString::startsWith
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:818
rtl::OString::operator=
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:311
rtl::OString::match
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:710
rtl_str_toDouble
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
stringutils.hxx