LibreOffice
LibreOffice 7.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 <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 #if defined LIBO_INTERNAL_ONLY
125 
131  OString( OString && str ) noexcept
132  {
133  pData = str.pData;
134  str.pData = nullptr;
135  rtl_string_new( &str.pData );
136  }
137 #endif
138 
144  OString( rtl_String * str )
145  {
146  pData = str;
147  rtl_string_acquire( pData );
148  }
149 
157  OString( rtl_String * str, __sal_NoAcquire )
158  {
159  pData = str;
160  }
161 
167  explicit OString( sal_Char value )
168  : pData (NULL)
169  {
170  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
171  }
172 
181  template< typename T >
183  {
184  pData = NULL;
185  rtl_string_newFromStr( &pData, value );
186  }
187 
188  template< typename T >
190  {
191  pData = NULL;
192  rtl_string_newFromStr( &pData, value );
193  }
194 
205  template< typename T >
207  {
208  assert(
210  pData = NULL;
212  rtl_string_new(&pData);
213  } else {
215  &pData,
217  literal),
219  }
220 #ifdef RTL_STRING_UNITTEST
221  rtl_string_unittest_const_literal = true;
222 #endif
223  }
224 
233  OString( const sal_Char * value, sal_Int32 length )
234  {
235  pData = NULL;
236  rtl_string_newFromStr_WithLength( &pData, value, length );
237  }
238 
253  OString( const sal_Unicode * value, sal_Int32 length,
254  rtl_TextEncoding encoding,
255  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
256  {
257  pData = NULL;
258  rtl_uString2String( &pData, value, length, encoding, convertFlags );
259  if (pData == NULL) {
260  throw std::bad_alloc();
261  }
262  }
263 
264 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
265 
269  template< typename T1, typename T2 >
270  OString( OStringConcat< T1, T2 >&& c )
271  {
272  const sal_Int32 l = c.length();
273  pData = rtl_string_alloc( l );
274  if (l != 0)
275  {
276  char* end = c.addData( pData->buffer );
277  pData->length = l;
278  *end = '\0';
279  }
280  }
281 
286  template< typename T >
287  OString( OStringNumber< T >&& n )
288  : OString( n.buf, n.length )
289  {}
290 #endif
291 
292 #ifdef LIBO_INTERNAL_ONLY
293  OString(std::nullptr_t) = delete;
294 #endif
295 
300  {
301  rtl_string_release( pData );
302  }
303 
309  OString & operator=( const OString & str )
310  {
311  rtl_string_assign( &pData, str.pData );
312  return *this;
313  }
314 
315 #if defined LIBO_INTERNAL_ONLY
316 
322  OString & operator=( OString && str ) noexcept
323  {
324  rtl_string_release( pData );
325  pData = str.pData;
326  str.pData = nullptr;
327  rtl_string_new( &str.pData );
328  return *this;
329  }
330 #endif
331 
337  template< typename T >
339  {
340  RTL_STRING_CONST_FUNCTION
341  assert(
344  rtl_string_new(&pData);
345  } else {
347  &pData,
349  literal),
351  }
352  return *this;
353  }
354 
360  OString & operator+=( const OString & str )
361 #if defined LIBO_INTERNAL_ONLY
362  &
363 #endif
364  {
365  rtl_string_newConcat( &pData, pData, str.pData );
366  return *this;
367  }
368 #if defined LIBO_INTERNAL_ONLY
369  void operator+=(OString const &) && = delete;
370 #endif
371 
372 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
373 
377  template< typename T1, typename T2 >
378  OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
379  sal_Int32 l = c.length();
380  if( l == 0 )
381  return *this;
382  l += pData->length;
383  rtl_string_ensureCapacity( &pData, l );
384  char* end = c.addData( pData->buffer + pData->length );
385  *end = '\0';
386  pData->length = l;
387  return *this;
388  }
389  template<typename T1, typename T2> void operator +=(
390  OStringConcat<T1, T2> &&) && = delete;
391 
396  template< typename T >
397  OString& operator+=( OStringNumber< T >&& n ) & {
398  sal_Int32 l = n.length;
399  if( l == 0 )
400  return *this;
401  l += pData->length;
402  rtl_string_ensureCapacity( &pData, l );
403  char* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
404  *end = '\0';
405  pData->length = l;
406  return *this;
407  }
408  template<typename T> void operator +=(
409  OStringNumber<T> &&) && = delete;
410 #endif
411 
416  void clear()
417  {
418  rtl_string_new( &pData );
419  }
420 
429  sal_Int32 getLength() const { return pData->length; }
430 
439  bool isEmpty() const
440  {
441  return pData->length == 0;
442  }
443 
455  const sal_Char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
456 
466  sal_Char operator [](sal_Int32 index) const {
467  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
468  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
469  return getStr()[index];
470  }
471 
484  sal_Int32 compareTo( const OString & str ) const
485  {
486  return rtl_str_compare_WithLength( pData->buffer, pData->length,
487  str.pData->buffer, str.pData->length );
488  }
489 
503  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
504  {
505  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
506  rObj.pData->buffer, rObj.pData->length, maxLength );
507  }
508 
521  sal_Int32 reverseCompareTo( const OString & str ) const
522  {
523  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
524  str.pData->buffer, str.pData->length );
525  }
526 
538  bool equals( const OString & str ) const
539  {
540  if ( pData->length != str.pData->length )
541  return false;
542  if ( pData == str.pData )
543  return true;
544  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
545  str.pData->buffer, str.pData->length ) == 0;
546  }
547 
563  bool equalsL( const sal_Char* value, sal_Int32 length ) const
564  {
565  if ( pData->length != length )
566  return false;
567 
568  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
569  value, length ) == 0;
570  }
571 
586  bool equalsIgnoreAsciiCase( const OString & str ) const
587  {
588  if ( pData->length != str.pData->length )
589  return false;
590  if ( pData == str.pData )
591  return true;
592  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
593  str.pData->buffer, str.pData->length ) == 0;
594  }
595 
617  template< typename T >
619  {
620  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
621  }
622 
623  template< typename T >
625  {
626  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
627  }
628 
634  template< typename T >
636  {
637  RTL_STRING_CONST_FUNCTION
638  assert(
640  return
641  (pData->length
644  pData->buffer, pData->length,
646  literal),
648  == 0);
649  }
650 
670  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
671  {
672  if ( pData->length != asciiStrLength )
673  return false;
674 
675  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
676  asciiStr, asciiStrLength ) == 0;
677  }
678 
694  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
695  {
696  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
697  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
698  }
699 
705  template< typename T >
706  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
707  {
708  RTL_STRING_CONST_FUNCTION
709  assert(
711  return
713  pData->buffer + fromIndex, pData->length - fromIndex,
715  literal),
718  == 0;
719  }
720 
737  bool matchL(
738  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
739  const
740  {
742  pData->buffer + fromIndex, pData->length - fromIndex,
743  str, strLength, strLength) == 0;
744  }
745 
746  // This overload is left undefined, to detect calls of matchL that
747  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
748  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
749  // platforms):
750 #if SAL_TYPES_SIZEOFLONG == 8
751  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
752 #endif
753 
772  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
773  {
774  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
775  str.pData->buffer, str.pData->length,
776  str.pData->length ) == 0;
777  }
778 
784  template< typename T >
785  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
786  {
787  RTL_STRING_CONST_FUNCTION
788  assert(
790  return
792  pData->buffer+fromIndex, pData->length-fromIndex,
794  literal),
797  == 0;
798  }
799 
814  bool startsWith(OString const & str, OString * rest = NULL) const {
815  bool b = match(str);
816  if (b && rest != NULL) {
817  *rest = copy(str.getLength());
818  }
819  return b;
820  }
821 
827  template< typename T >
829  T & literal, OString * rest = NULL) const
830  {
831  RTL_STRING_CONST_FUNCTION
832  bool b = match(literal, 0);
833  if (b && rest != NULL) {
834  *rest = copy(
836  }
837  return b;
838  }
839 
859  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
860  const
861  {
862  bool b = matchIgnoreAsciiCase(str);
863  if (b && rest != NULL) {
864  *rest = copy(str.getLength());
865  }
866  return b;
867  }
868 
874  template< typename T >
876  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
877  {
878  RTL_STRING_CONST_FUNCTION
879  assert(
881  bool b = matchIgnoreAsciiCase(literal);
882  if (b && rest != NULL) {
883  *rest = copy(
885  }
886  return b;
887  }
888 
903  bool endsWith(OString const & str, OString * rest = NULL) const {
904  bool b = str.getLength() <= getLength()
905  && match(str, getLength() - str.getLength());
906  if (b && rest != NULL) {
907  *rest = copy(0, getLength() - str.getLength());
908  }
909  return b;
910  }
911 
917  template< typename T >
919  T & literal, OString * rest = NULL) const
920  {
921  RTL_STRING_CONST_FUNCTION
922  assert(
924  bool b
926  <= sal_uInt32(getLength()))
927  && match(
929  literal),
930  (getLength()
932  if (b && rest != NULL) {
933  *rest = copy(
934  0,
935  (getLength()
937  }
938  return b;
939  }
940 
954  bool endsWithL(char const * str, sal_Int32 strLength) const {
955  return strLength <= getLength()
956  && matchL(str, strLength, getLength() - strLength);
957  }
958 
959  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
960  { return rStr1.equals(rStr2); }
961  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
962  { return !(operator == ( rStr1, rStr2 )); }
963  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
964  { return rStr1.compareTo( rStr2 ) < 0; }
965  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
966  { return rStr1.compareTo( rStr2 ) > 0; }
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 
972  template< typename T >
973  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
974  {
975  return rStr1.compareTo( value ) == 0;
976  }
977 
978  template< typename T >
980  {
981  return rStr1.compareTo( value ) == 0;
982  }
983 
984  template< typename T >
985  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
986  {
987  return rStr2.compareTo( value ) == 0;
988  }
989 
990  template< typename T >
992  {
993  return rStr2.compareTo( value ) == 0;
994  }
995 
1001  template< typename T >
1003  {
1004  RTL_STRING_CONST_FUNCTION
1005  assert(
1007  return
1008  (rStr.getLength()
1011  rStr.pData->buffer, rStr.pData->length,
1013  literal),
1015  == 0);
1016  }
1017 
1023  template< typename T >
1025  {
1026  RTL_STRING_CONST_FUNCTION
1027  assert(
1029  return
1030  (rStr.getLength()
1033  rStr.pData->buffer, rStr.pData->length,
1035  literal),
1037  == 0);
1038  }
1039 
1040  template< typename T >
1041  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1042  {
1043  return !(operator == ( rStr1, value ));
1044  }
1045 
1046  template< typename T >
1048  {
1049  return !(operator == ( rStr1, value ));
1050  }
1051 
1052  template< typename T >
1053  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1054  {
1055  return !(operator == ( value, rStr2 ));
1056  }
1057 
1058  template< typename T >
1060  {
1061  return !(operator == ( value, rStr2 ));
1062  }
1063 
1069  template< typename T >
1071  {
1072  return !( rStr == literal );
1073  }
1074 
1080  template< typename T >
1082  {
1083  return !( literal == rStr );
1084  }
1085 
1093  sal_Int32 hashCode() const
1094  {
1095  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1096  }
1097 
1111  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1112  {
1113  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1114  return (ret < 0 ? ret : ret+fromIndex);
1115  }
1116 
1126  sal_Int32 lastIndexOf( sal_Char ch ) const
1127  {
1128  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1129  }
1130 
1143  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1144  {
1145  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1146  }
1147 
1163  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1164  {
1165  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1166  str.pData->buffer, str.pData->length );
1167  return (ret < 0 ? ret : ret+fromIndex);
1168  }
1169 
1175  template< typename T >
1176  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1177  {
1178  RTL_STRING_CONST_FUNCTION
1179  assert(
1181  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1182  pData->buffer + fromIndex, pData->length - fromIndex,
1185  return n < 0 ? n : n + fromIndex;
1186  }
1187 
1206  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1207  const
1208  {
1209  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1210  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1211  return n < 0 ? n : n + fromIndex;
1212  }
1213 
1214  // This overload is left undefined, to detect calls of indexOfL that
1215  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1216  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1217  // platforms):
1218 #if SAL_TYPES_SIZEOFLONG == 8
1219  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1220 #endif
1221 
1237  sal_Int32 lastIndexOf( const OString & str ) const
1238  {
1239  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1240  str.pData->buffer, str.pData->length );
1241  }
1242 
1260  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1261  {
1262  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1263  str.pData->buffer, str.pData->length );
1264  }
1265 
1276  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1277  {
1278  return copy(beginIndex, getLength() - beginIndex);
1279  }
1280 
1293  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1294  {
1295  rtl_String *pNew = NULL;
1296  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1297  return OString( pNew, SAL_NO_ACQUIRE );
1298  }
1299 
1309  {
1310  rtl_String* pNew = NULL;
1311  rtl_string_newConcat( &pNew, pData, str.pData );
1312  return OString( pNew, SAL_NO_ACQUIRE );
1313  }
1314 
1315 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1316  friend OString operator+( const OString & str1, const OString & str2 )
1317  {
1318  return str1.concat( str2 );
1319  }
1320 #endif
1321 
1335  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1336  {
1337  rtl_String* pNew = NULL;
1338  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1339  return OString( pNew, SAL_NO_ACQUIRE );
1340  }
1341 
1356  {
1357  rtl_String* pNew = NULL;
1358  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1359  return OString( pNew, SAL_NO_ACQUIRE );
1360  }
1361 
1381  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1382  {
1383  rtl_String * s = NULL;
1384  sal_Int32 i = 0;
1386  &s, pData, from.pData->buffer, from.pData->length,
1387  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1388  return OString(s, SAL_NO_ACQUIRE);
1389  }
1390 
1404  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1405  rtl_String * s = NULL;
1407  &s, pData, from.pData->buffer, from.pData->length,
1408  to.pData->buffer, to.pData->length);
1409  return OString(s, SAL_NO_ACQUIRE);
1410  }
1411 
1423  {
1424  rtl_String* pNew = NULL;
1425  rtl_string_newToAsciiLowerCase( &pNew, pData );
1426  return OString( pNew, SAL_NO_ACQUIRE );
1427  }
1428 
1440  {
1441  rtl_String* pNew = NULL;
1442  rtl_string_newToAsciiUpperCase( &pNew, pData );
1443  return OString( pNew, SAL_NO_ACQUIRE );
1444  }
1445 
1458  {
1459  rtl_String* pNew = NULL;
1460  rtl_string_newTrim( &pNew, pData );
1461  return OString( pNew, SAL_NO_ACQUIRE );
1462  }
1463 
1488  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1489  {
1490  rtl_String * pNew = NULL;
1491  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1492  return OString( pNew, SAL_NO_ACQUIRE );
1493  }
1494 
1508  OString getToken(sal_Int32 count, char separator) const {
1509  sal_Int32 n = 0;
1510  return getToken(count, separator, n);
1511  }
1512 
1521  bool toBoolean() const
1522  {
1523  return rtl_str_toBoolean( pData->buffer );
1524  }
1525 
1533  {
1534  return pData->buffer[0];
1535  }
1536 
1547  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1548  {
1549  return rtl_str_toInt32( pData->buffer, radix );
1550  }
1551 
1564  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1565  {
1566  return rtl_str_toUInt32( pData->buffer, radix );
1567  }
1568 
1579  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1580  {
1581  return rtl_str_toInt64( pData->buffer, radix );
1582  }
1583 
1596  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1597  {
1598  return rtl_str_toUInt64( pData->buffer, radix );
1599  }
1600 
1609  float toFloat() const
1610  {
1611  return rtl_str_toFloat( pData->buffer );
1612  }
1613 
1622  double toDouble() const
1623  {
1624  return rtl_str_toDouble( pData->buffer );
1625  }
1626 
1627 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1628 
1629  static OStringNumber< int > number( int i, sal_Int16 radix = 10 )
1630  {
1631  return OStringNumber< int >( i, radix );
1632  }
1633  static OStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
1634  {
1635  return OStringNumber< long long >( ll, radix );
1636  }
1637  static OStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
1638  {
1639  return OStringNumber< unsigned long long >( ll, radix );
1640  }
1641  static OStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
1642  {
1643  return number( static_cast< unsigned long long >( i ), radix );
1644  }
1645  static OStringNumber< long long > number( long i, sal_Int16 radix = 10)
1646  {
1647  return number( static_cast< long long >( i ), radix );
1648  }
1649  static OStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
1650  {
1651  return number( static_cast< unsigned long long >( i ), radix );
1652  }
1653  static OStringNumber< float > number( float f )
1654  {
1655  return OStringNumber< float >( f );
1656  }
1657  static OStringNumber< double > number( double d )
1658  {
1659  return OStringNumber< double >( d );
1660  }
1661 #else
1662 
1672  static OString number( int i, sal_Int16 radix = 10 )
1673  {
1675  return OString(aBuf, rtl_str_valueOfInt32(aBuf, i, radix));
1676  }
1679  static OString number( unsigned int i, sal_Int16 radix = 10 )
1680  {
1681  return number( static_cast< unsigned long long >( i ), radix );
1682  }
1685  static OString number( long i, sal_Int16 radix = 10 )
1686  {
1687  return number( static_cast< long long >( i ), radix );
1688  }
1691  static OString number( unsigned long i, sal_Int16 radix = 10 )
1692  {
1693  return number( static_cast< unsigned long long >( i ), radix );
1694  }
1697  static OString number( long long ll, sal_Int16 radix = 10 )
1698  {
1700  return OString(aBuf, rtl_str_valueOfInt64(aBuf, ll, radix));
1701  }
1704  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1705  {
1707  return OString(aBuf, rtl_str_valueOfUInt64(aBuf, ll, radix));
1708  }
1709 
1719  static OString number( float f )
1720  {
1722  return OString(aBuf, rtl_str_valueOfFloat(aBuf, f));
1723  }
1724 
1734  static OString number( double d )
1735  {
1737  return OString(aBuf, rtl_str_valueOfDouble(aBuf, d));
1738  }
1739 #endif
1740 
1752  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1753  {
1754  return boolean(b);
1755  }
1756 
1768  static OString boolean( bool b )
1769  {
1771  return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
1772  }
1773 
1781  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1782  {
1783  return OString( &c, 1 );
1784  }
1785 
1796  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1797  {
1798  return number( i, radix );
1799  }
1800 
1811  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1812  {
1813  return number( ll, radix );
1814  }
1815 
1825  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1826  {
1827  return number(f);
1828  }
1829 
1839  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1840  {
1841  return number(d);
1842  }
1843 
1844 #if defined LIBO_INTERNAL_ONLY
1845  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
1846 #endif
1847 };
1848 
1849 /* ======================================================================= */
1850 
1851 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1852 
1860 struct SAL_WARN_UNUSED OStringLiteral
1861 {
1862  template< int N >
1863  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1864 #if defined __cpp_char8_t
1865  template< int N >
1866  explicit OStringLiteral( const char8_t (&str)[ N ] ) : size( N - 1 ), data( reinterpret_cast<char const *>(str) ) { assert( strlen( data ) == N - 1 ); }
1867 #endif
1868  int size;
1869  const char* data;
1870 };
1871 
1875 template<>
1876 struct ToStringHelper< OString >
1877  {
1878  static std::size_t length( const OString& s ) { return s.getLength(); }
1879  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1880  static const bool allowOStringConcat = true;
1881  static const bool allowOUStringConcat = false;
1882  };
1883 
1887 template<>
1888 struct ToStringHelper< OStringLiteral >
1889  {
1890  static std::size_t length( const OStringLiteral& str ) { return str.size; }
1891  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1892  static const bool allowOStringConcat = true;
1893  static const bool allowOUStringConcat = false;
1894  };
1895 
1899 template< typename charT, typename traits, typename T1, typename T2 >
1900 inline std::basic_ostream<charT, traits> & operator <<(
1901  std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
1902 {
1903  return stream << OString( std::move(concat) );
1904 }
1905 #endif
1906 
1907 
1914 {
1924  size_t operator()( const OString& rString ) const
1925  { return static_cast<size_t>(rString.hashCode()); }
1926 };
1927 
1930 {
1931  bool operator()( const char* p1, const char* p2) const
1932  { return rtl_str_compare(p1, p2) == 0; }
1933 };
1934 
1937 {
1938  size_t operator()(const char* p) const
1939  { return rtl_str_hashCode(p); }
1940 };
1941 
1942 /* ======================================================================= */
1943 
1950 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1951 operator <<(
1952  std::basic_ostream<charT, traits> & stream, OString const & rString)
1953 {
1954  return stream << rString.getStr();
1955  // best effort; potentially loses data due to embedded null characters
1956 }
1957 
1958 } /* Namespace */
1959 
1960 #ifdef RTL_STRING_UNITTEST
1961 namespace rtl
1962 {
1963 typedef rtlunittest::OString OString;
1964 }
1965 #undef RTL_STRING_CONST_FUNCTION
1966 #endif
1967 
1968 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1969 using ::rtl::OString;
1970 using ::rtl::OStringChar;
1971 using ::rtl::OStringHash;
1972 using ::rtl::OStringLiteral;
1973 #endif
1974 
1976 
1981 #if defined LIBO_INTERNAL_ONLY
1982 namespace std {
1983 
1984 template<>
1985 struct hash<::rtl::OString>
1986 {
1987  std::size_t operator()(::rtl::OString const & s) const
1988  { return std::size_t(s.hashCode()); }
1989 };
1990 
1991 }
1992 
1993 #endif
1994 
1996 #endif // INCLUDED_RTL_STRING_HXX
1997 
1998 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OString::operator+=
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:360
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:116
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:979
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:206
rtl::OString::operator+
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1316
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:1930
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:253
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:903
rtl::CStringHash::operator()
size_t operator()(const char *p) const
Definition: string.hxx:1938
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:1734
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:1024
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:1237
rtl::OString::operator==
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:973
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:144
rtl::OString::reverseCompareTo
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:521
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:370
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:1521
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:1047
rtl::OString::OString
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:167
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:918
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:1697
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:859
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:954
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:576
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:624
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:1081
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:828
rtl::OString::operator==
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:991
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:635
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:694
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:1041
rtl::OString::getToken
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1508
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:1579
rtl::OString::toUInt32
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1564
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:1355
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:299
sal_Bool
unsigned char sal_Bool
Definition: types.h:34
rtl::OStringHash::operator()
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1924
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:1691
rtl::OString::equals
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:538
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:1308
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:182
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:1422
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:1704
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:1293
rtl::OString::equalsL
bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:563
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:1111
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:1768
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:1143
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:1335
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:1679
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:1070
rtl::OString::clear
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:416
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:1457
rtl::OString::toFloat
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1609
rtl::OString::compareTo
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:484
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:1685
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:367
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:1002
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:1163
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:1532
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:737
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:463
rtl::OString::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:455
rtl::CStringEqual::operator()
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1931
rtl::OString::number
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1672
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:1126
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:1596
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:1276
rtl::OStringHash
A helper to use OStrings with hash maps.
Definition: string.hxx:1914
rtl::OString::equalsIgnoreAsciiCaseL
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:670
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:876
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:298
rtl::OString::toDouble
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1622
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:1206
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:429
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:772
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:137
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:618
rtl::OString::OString
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:157
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:1380
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:1488
rtl::OString::operator!=
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1053
rtl::OString::hashCode
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1093
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:503
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:1439
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:785
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:1260
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:1951
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:985
rtl::OString::OString
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:233
rtl::OString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:439
rtl::OString::equalsIgnoreAsciiCase
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:586
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:1719
rtl::CStringHash
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1937
rtl::OString::OString
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:189
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:338
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:1404
rtl::OString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1547
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:1176
rtl::OString::operator!=
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1059
rtl::OString::startsWith
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:814
rtl::OString::operator=
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:309
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:706
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