LibreOffice
LibreOffice 6.2 SDK C/C++ API Reference
string.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_STRING_HXX
21 #define INCLUDED_RTL_STRING_HXX
22 
23 #include "sal/config.h"
24 
25 #include <cassert>
26 #include <cstddef>
27 #include <new>
28 #include <ostream>
29 #include <string.h>
30 
31 #include "rtl/textenc.h"
32 #include "rtl/string.h"
33 #include "rtl/stringutils.hxx"
34 
35 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
36 #include "rtl/stringconcat.hxx"
37 #endif
38 
39 #ifdef RTL_STRING_UNITTEST
40 extern bool rtl_string_unittest_const_literal;
41 extern bool rtl_string_unittest_const_literal_function;
42 #endif
43 
44 // The unittest uses slightly different code to help check that the proper
45 // calls are made. The class is put into a different namespace to make
46 // sure the compiler generates a different (if generating also non-inline)
47 // copy of the function and does not merge them together. The class
48 // is "brought" into the proper rtl namespace by a typedef below.
49 #ifdef RTL_STRING_UNITTEST
50 #define rtl rtlunittest
51 #endif
52 
53 namespace rtl
54 {
55 
57 #ifdef RTL_STRING_UNITTEST
58 #undef rtl
59 // helper macro to make functions appear more readable
60 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
61 #else
62 #define RTL_STRING_CONST_FUNCTION
63 #endif
64 
66 /* ======================================================================= */
67 
92 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
93 {
94 public:
96  rtl_String * pData;
98 
103  {
104  pData = NULL;
105  rtl_string_new( &pData );
106  }
107 
113  OString( const OString & str )
114  {
115  pData = str.pData;
116  rtl_string_acquire( pData );
117  }
118 
119 #ifndef _MSC_VER // TODO?
120 #if defined LIBO_INTERNAL_ONLY
121 
127  OString( OString && str )
128  {
129  pData = str.pData;
130  str.pData = nullptr;
131  rtl_string_new( &str.pData );
132  }
133 #endif
134 #endif
135 
141  OString( rtl_String * str )
142  {
143  pData = str;
144  rtl_string_acquire( pData );
145  }
146 
154  OString( rtl_String * str, __sal_NoAcquire )
155  {
156  pData = str;
157  }
158 
164  explicit OString( sal_Char value )
165  : pData (NULL)
166  {
167  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
168  }
169 
178  template< typename T >
180  {
181  pData = NULL;
182  rtl_string_newFromStr( &pData, value );
183  }
184 
185  template< typename T >
187  {
188  pData = NULL;
189  rtl_string_newFromStr( &pData, value );
190  }
191 
202  template< typename T >
204  {
205  assert(
207  pData = NULL;
209  rtl_string_new(&pData);
210  } else {
212  &pData,
214  literal),
216  }
217 #ifdef RTL_STRING_UNITTEST
218  rtl_string_unittest_const_literal = true;
219 #endif
220  }
221 
230  OString( const sal_Char * value, sal_Int32 length )
231  {
232  pData = NULL;
233  rtl_string_newFromStr_WithLength( &pData, value, length );
234  }
235 
250  OString( const sal_Unicode * value, sal_Int32 length,
251  rtl_TextEncoding encoding,
252  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
253  {
254  pData = NULL;
255  rtl_uString2String( &pData, value, length, encoding, convertFlags );
256  if (pData == NULL) {
257  throw std::bad_alloc();
258  }
259  }
260 
261 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
262 
266  template< typename T1, typename T2 >
267  OString( OStringConcat< T1, T2 >&& c )
268  {
269  const sal_Int32 l = c.length();
270  pData = rtl_string_alloc( l );
271  if (l != 0)
272  {
273  char* end = c.addData( pData->buffer );
274  pData->length = l;
275  *end = '\0';
276  }
277  }
278 #endif
279 
280 #ifdef LIBO_INTERNAL_ONLY
281  OString(std::nullptr_t) = delete;
282 #endif
283 
288  {
289  rtl_string_release( pData );
290  }
291 
297  OString & operator=( const OString & str )
298  {
299  rtl_string_assign( &pData, str.pData );
300  return *this;
301  }
302 
303 #ifndef _MSC_VER // TODO?
304 #if defined LIBO_INTERNAL_ONLY
305 
311  OString & operator=( OString && str )
312  {
313  rtl_string_release( pData );
314  pData = str.pData;
315  str.pData = nullptr;
316  rtl_string_new( &str.pData );
317  return *this;
318  }
319 #endif
320 #endif
321 
327  template< typename T >
329  {
330  RTL_STRING_CONST_FUNCTION
331  assert(
334  rtl_string_new(&pData);
335  } else {
337  &pData,
339  literal),
341  }
342  return *this;
343  }
344 
350  OString & operator+=( const OString & str )
351 #if defined LIBO_INTERNAL_ONLY
352  &
353 #endif
354  {
355  rtl_string_newConcat( &pData, pData, str.pData );
356  return *this;
357  }
358 #if defined LIBO_INTERNAL_ONLY
359  void operator+=(OString const &) && = delete;
360 #endif
361 
362 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
363 
367  template< typename T1, typename T2 >
368  OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
369  sal_Int32 l = c.length();
370  if( l == 0 )
371  return *this;
372  l += pData->length;
373  rtl_string_ensureCapacity( &pData, l );
374  char* end = c.addData( pData->buffer + pData->length );
375  *end = '\0';
376  pData->length = l;
377  return *this;
378  }
379  template<typename T1, typename T2> void operator +=(
380  OStringConcat<T1, T2> &&) && = delete;
381 #endif
382 
387  void clear()
388  {
389  rtl_string_new( &pData );
390  }
391 
400  sal_Int32 getLength() const { return pData->length; }
401 
410  bool isEmpty() const
411  {
412  return pData->length == 0;
413  }
414 
426  const sal_Char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
427 
437  sal_Char operator [](sal_Int32 index) const {
438  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
439  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
440  return getStr()[index];
441  }
442 
455  sal_Int32 compareTo( const OString & str ) const
456  {
457  return rtl_str_compare_WithLength( pData->buffer, pData->length,
458  str.pData->buffer, str.pData->length );
459  }
460 
474  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
475  {
476  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
477  rObj.pData->buffer, rObj.pData->length, maxLength );
478  }
479 
492  sal_Int32 reverseCompareTo( const OString & str ) const
493  {
494  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
495  str.pData->buffer, str.pData->length );
496  }
497 
509  bool equals( const OString & str ) const
510  {
511  if ( pData->length != str.pData->length )
512  return false;
513  if ( pData == str.pData )
514  return true;
515  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
516  str.pData->buffer, str.pData->length ) == 0;
517  }
518 
534  bool equalsL( const sal_Char* value, sal_Int32 length ) const
535  {
536  if ( pData->length != length )
537  return false;
538 
539  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
540  value, length ) == 0;
541  }
542 
557  bool equalsIgnoreAsciiCase( const OString & str ) const
558  {
559  if ( pData->length != str.pData->length )
560  return false;
561  if ( pData == str.pData )
562  return true;
563  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
564  str.pData->buffer, str.pData->length ) == 0;
565  }
566 
588  template< typename T >
590  {
591  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
592  }
593 
594  template< typename T >
596  {
597  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
598  }
599 
605  template< typename T >
607  {
608  RTL_STRING_CONST_FUNCTION
609  assert(
611  return
612  (pData->length
615  pData->buffer, pData->length,
617  literal),
619  == 0);
620  }
621 
641  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
642  {
643  if ( pData->length != asciiStrLength )
644  return false;
645 
646  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
647  asciiStr, asciiStrLength ) == 0;
648  }
649 
665  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
666  {
667  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
668  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
669  }
670 
676  template< typename T >
677  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
678  {
679  RTL_STRING_CONST_FUNCTION
680  assert(
682  return
684  pData->buffer + fromIndex, pData->length - fromIndex,
686  literal),
689  == 0;
690  }
691 
708  bool matchL(
709  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
710  const
711  {
713  pData->buffer + fromIndex, pData->length - fromIndex,
714  str, strLength, strLength) == 0;
715  }
716 
717  // This overload is left undefined, to detect calls of matchL that
718  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
719  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
720  // platforms):
721 #if SAL_TYPES_SIZEOFLONG == 8
722  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
723 #endif
724 
743  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
744  {
745  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
746  str.pData->buffer, str.pData->length,
747  str.pData->length ) == 0;
748  }
749 
755  template< typename T >
756  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
757  {
758  RTL_STRING_CONST_FUNCTION
759  assert(
761  return
763  pData->buffer+fromIndex, pData->length-fromIndex,
765  literal),
768  == 0;
769  }
770 
785  bool startsWith(OString const & str, OString * rest = NULL) const {
786  bool b = match(str);
787  if (b && rest != NULL) {
788  *rest = copy(str.getLength());
789  }
790  return b;
791  }
792 
798  template< typename T >
800  T & literal, OString * rest = NULL) const
801  {
802  RTL_STRING_CONST_FUNCTION
803  bool b = match(literal, 0);
804  if (b && rest != NULL) {
805  *rest = copy(
807  }
808  return b;
809  }
810 
830  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
831  const
832  {
833  bool b = matchIgnoreAsciiCase(str);
834  if (b && rest != NULL) {
835  *rest = copy(str.getLength());
836  }
837  return b;
838  }
839 
845  template< typename T >
847  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
848  {
849  RTL_STRING_CONST_FUNCTION
850  assert(
852  bool b = matchIgnoreAsciiCase(literal);
853  if (b && rest != NULL) {
854  *rest = copy(
856  }
857  return b;
858  }
859 
874  bool endsWith(OString const & str, OString * rest = NULL) const {
875  bool b = str.getLength() <= getLength()
876  && match(str, getLength() - str.getLength());
877  if (b && rest != NULL) {
878  *rest = copy(0, getLength() - str.getLength());
879  }
880  return b;
881  }
882 
888  template< typename T >
890  T & literal, OString * rest = NULL) const
891  {
892  RTL_STRING_CONST_FUNCTION
893  assert(
895  bool b
897  <= sal_uInt32(getLength()))
898  && match(
900  literal),
901  (getLength()
903  if (b && rest != NULL) {
904  *rest = copy(
905  0,
906  (getLength()
908  }
909  return b;
910  }
911 
925  bool endsWithL(char const * str, sal_Int32 strLength) const {
926  return strLength <= getLength()
927  && matchL(str, strLength, getLength() - strLength);
928  }
929 
930  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
931  { return rStr1.equals(rStr2); }
932  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
933  { return !(operator == ( rStr1, rStr2 )); }
934  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
935  { return rStr1.compareTo( rStr2 ) < 0; }
936  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
937  { return rStr1.compareTo( rStr2 ) > 0; }
938  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
939  { return rStr1.compareTo( rStr2 ) <= 0; }
940  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
941  { return rStr1.compareTo( rStr2 ) >= 0; }
942 
943  template< typename T >
944  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
945  {
946  return rStr1.compareTo( value ) == 0;
947  }
948 
949  template< typename T >
951  {
952  return rStr1.compareTo( value ) == 0;
953  }
954 
955  template< typename T >
956  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
957  {
958  return rStr2.compareTo( value ) == 0;
959  }
960 
961  template< typename T >
963  {
964  return rStr2.compareTo( value ) == 0;
965  }
966 
972  template< typename T >
974  {
975  RTL_STRING_CONST_FUNCTION
976  assert(
978  return
979  (rStr.getLength()
982  rStr.pData->buffer, rStr.pData->length,
984  literal),
986  == 0);
987  }
988 
994  template< typename T >
996  {
997  RTL_STRING_CONST_FUNCTION
998  assert(
1000  return
1001  (rStr.getLength()
1004  rStr.pData->buffer, rStr.pData->length,
1006  literal),
1008  == 0);
1009  }
1010 
1011  template< typename T >
1012  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1013  {
1014  return !(operator == ( rStr1, value ));
1015  }
1016 
1017  template< typename T >
1019  {
1020  return !(operator == ( rStr1, value ));
1021  }
1022 
1023  template< typename T >
1024  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1025  {
1026  return !(operator == ( value, rStr2 ));
1027  }
1028 
1029  template< typename T >
1031  {
1032  return !(operator == ( value, rStr2 ));
1033  }
1034 
1040  template< typename T >
1042  {
1043  return !( rStr == literal );
1044  }
1045 
1051  template< typename T >
1053  {
1054  return !( literal == rStr );
1055  }
1056 
1064  sal_Int32 hashCode() const
1065  {
1066  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1067  }
1068 
1082  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1083  {
1084  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1085  return (ret < 0 ? ret : ret+fromIndex);
1086  }
1087 
1097  sal_Int32 lastIndexOf( sal_Char ch ) const
1098  {
1099  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1100  }
1101 
1114  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1115  {
1116  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1117  }
1118 
1134  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1135  {
1136  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1137  str.pData->buffer, str.pData->length );
1138  return (ret < 0 ? ret : ret+fromIndex);
1139  }
1140 
1146  template< typename T >
1147  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1148  {
1149  RTL_STRING_CONST_FUNCTION
1150  assert(
1152  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1153  pData->buffer + fromIndex, pData->length - fromIndex,
1156  return n < 0 ? n : n + fromIndex;
1157  }
1158 
1177  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1178  const
1179  {
1180  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1181  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1182  return n < 0 ? n : n + fromIndex;
1183  }
1184 
1185  // This overload is left undefined, to detect calls of indexOfL that
1186  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1187  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1188  // platforms):
1189 #if SAL_TYPES_SIZEOFLONG == 8
1190  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1191 #endif
1192 
1208  sal_Int32 lastIndexOf( const OString & str ) const
1209  {
1210  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1211  str.pData->buffer, str.pData->length );
1212  }
1213 
1231  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1232  {
1233  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1234  str.pData->buffer, str.pData->length );
1235  }
1236 
1247  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1248  {
1249  rtl_String *pNew = NULL;
1250  rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1251  return OString( pNew, SAL_NO_ACQUIRE );
1252  }
1253 
1266  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1267  {
1268  rtl_String *pNew = NULL;
1269  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1270  return OString( pNew, SAL_NO_ACQUIRE );
1271  }
1272 
1282  {
1283  rtl_String* pNew = NULL;
1284  rtl_string_newConcat( &pNew, pData, str.pData );
1285  return OString( pNew, SAL_NO_ACQUIRE );
1286  }
1287 
1288 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1289  friend OString operator+( const OString & str1, const OString & str2 )
1290  {
1291  return str1.concat( str2 );
1292  }
1293 #endif
1294 
1308  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1309  {
1310  rtl_String* pNew = NULL;
1311  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1312  return OString( pNew, SAL_NO_ACQUIRE );
1313  }
1314 
1329  {
1330  rtl_String* pNew = NULL;
1331  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1332  return OString( pNew, SAL_NO_ACQUIRE );
1333  }
1334 
1354  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1355  {
1356  rtl_String * s = NULL;
1357  sal_Int32 i = 0;
1359  &s, pData, from.pData->buffer, from.pData->length,
1360  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1361  return OString(s, SAL_NO_ACQUIRE);
1362  }
1363 
1377  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1378  rtl_String * s = NULL;
1380  &s, pData, from.pData->buffer, from.pData->length,
1381  to.pData->buffer, to.pData->length);
1382  return OString(s, SAL_NO_ACQUIRE);
1383  }
1384 
1396  {
1397  rtl_String* pNew = NULL;
1398  rtl_string_newToAsciiLowerCase( &pNew, pData );
1399  return OString( pNew, SAL_NO_ACQUIRE );
1400  }
1401 
1413  {
1414  rtl_String* pNew = NULL;
1415  rtl_string_newToAsciiUpperCase( &pNew, pData );
1416  return OString( pNew, SAL_NO_ACQUIRE );
1417  }
1418 
1431  {
1432  rtl_String* pNew = NULL;
1433  rtl_string_newTrim( &pNew, pData );
1434  return OString( pNew, SAL_NO_ACQUIRE );
1435  }
1436 
1461  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1462  {
1463  rtl_String * pNew = NULL;
1464  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1465  return OString( pNew, SAL_NO_ACQUIRE );
1466  }
1467 
1481  OString getToken(sal_Int32 count, char separator) const {
1482  sal_Int32 n = 0;
1483  return getToken(count, separator, n);
1484  }
1485 
1494  bool toBoolean() const
1495  {
1496  return rtl_str_toBoolean( pData->buffer );
1497  }
1498 
1506  {
1507  return pData->buffer[0];
1508  }
1509 
1520  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1521  {
1522  return rtl_str_toInt32( pData->buffer, radix );
1523  }
1524 
1537  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1538  {
1539  return rtl_str_toUInt32( pData->buffer, radix );
1540  }
1541 
1552  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1553  {
1554  return rtl_str_toInt64( pData->buffer, radix );
1555  }
1556 
1569  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1570  {
1571  return rtl_str_toUInt64( pData->buffer, radix );
1572  }
1573 
1582  float toFloat() const
1583  {
1584  return rtl_str_toFloat( pData->buffer );
1585  }
1586 
1595  double toDouble() const
1596  {
1597  return rtl_str_toDouble( pData->buffer );
1598  }
1599 
1610  static OString number( int i, sal_Int16 radix = 10 )
1611  {
1612  return number( static_cast< long long >( i ), radix );
1613  }
1616  static OString number( unsigned int i, sal_Int16 radix = 10 )
1617  {
1618  return number( static_cast< unsigned long long >( i ), radix );
1619  }
1622  static OString number( long i, sal_Int16 radix = 10 )
1623  {
1624  return number( static_cast< long long >( i ), radix );
1625  }
1628  static OString number( unsigned long i, sal_Int16 radix = 10 )
1629  {
1630  return number( static_cast< unsigned long long >( i ), radix );
1631  }
1634  static OString number( long long ll, sal_Int16 radix = 10 )
1635  {
1637  rtl_String* pNewData = NULL;
1638  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1639  return OString( pNewData, SAL_NO_ACQUIRE );
1640  }
1643  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1644  {
1646  rtl_String* pNewData = NULL;
1647  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1648  return OString( pNewData, SAL_NO_ACQUIRE );
1649  }
1650 
1660  static OString number( float f )
1661  {
1663  rtl_String* pNewData = NULL;
1664  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1665  return OString( pNewData, SAL_NO_ACQUIRE );
1666  }
1667 
1677  static OString number( double d )
1678  {
1680  rtl_String* pNewData = NULL;
1681  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1682  return OString( pNewData, SAL_NO_ACQUIRE );
1683  }
1684 
1696  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1697  {
1698  return boolean(b);
1699  }
1700 
1712  static OString boolean( bool b )
1713  {
1715  rtl_String* pNewData = NULL;
1716  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1717  return OString( pNewData, SAL_NO_ACQUIRE );
1718  }
1719 
1727  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1728  {
1729  return OString( &c, 1 );
1730  }
1731 
1742  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1743  {
1744  return number( i, radix );
1745  }
1746 
1757  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1758  {
1759  return number( ll, radix );
1760  }
1761 
1771  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1772  {
1773  return number(f);
1774  }
1775 
1785  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1786  {
1787  return number(d);
1788  }
1789 
1790 };
1791 
1792 /* ======================================================================= */
1793 
1794 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1795 
1803 struct SAL_WARN_UNUSED OStringLiteral
1804 {
1805  template< int N >
1806  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1807  int size;
1808  const char* data;
1809 };
1810 
1814 template<>
1815 struct ToStringHelper< OString >
1816  {
1817  static int length( const OString& s ) { return s.getLength(); }
1818  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1819  static const bool allowOStringConcat = true;
1820  static const bool allowOUStringConcat = false;
1821  };
1822 
1826 template<>
1827 struct ToStringHelper< OStringLiteral >
1828  {
1829  static int length( const OStringLiteral& str ) { return str.size; }
1830  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1831  static const bool allowOStringConcat = true;
1832  static const bool allowOUStringConcat = false;
1833  };
1834 
1838 template< typename charT, typename traits, typename T1, typename T2 >
1839 inline std::basic_ostream<charT, traits> & operator <<(
1840  std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
1841 {
1842  return stream << OString( std::move(concat) );
1843 }
1844 #endif
1845 
1846 
1853 {
1863  size_t operator()( const OString& rString ) const
1864  { return static_cast<size_t>(rString.hashCode()); }
1865 };
1866 
1869 {
1870  bool operator()( const char* p1, const char* p2) const
1871  { return rtl_str_compare(p1, p2) == 0; }
1872 };
1873 
1876 {
1877  size_t operator()(const char* p) const
1878  { return rtl_str_hashCode(p); }
1879 };
1880 
1881 /* ======================================================================= */
1882 
1889 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1891  std::basic_ostream<charT, traits> & stream, OString const & rString)
1892 {
1893  return stream << rString.getStr();
1894  // best effort; potentially loses data due to embedded null characters
1895 }
1896 
1897 } /* Namespace */
1898 
1899 #ifdef RTL_STRING_UNITTEST
1900 namespace rtl
1901 {
1902 typedef rtlunittest::OString OString;
1903 }
1904 #undef RTL_STRING_CONST_FUNCTION
1905 #endif
1906 
1907 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1908 using ::rtl::OString;
1909 using ::rtl::OStringHash;
1910 using ::rtl::OStringLiteral;
1911 #endif
1912 
1914 
1919 #if defined LIBO_INTERNAL_ONLY
1920 namespace std {
1921 
1922 template<>
1923 struct hash<::rtl::OString>
1924 {
1925  std::size_t operator()(::rtl::OString const & s) const
1926  { return std::size_t(s.hashCode()); }
1927 };
1928 
1929 }
1930 
1931 #endif
1932 
1934 #endif // INCLUDED_RTL_STRING_HXX
1935 
1936 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const sal_Char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC void rtl_string_newReplaceFirst(rtl_String **newStr, rtl_String *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Char toChar() const
Returns the first character from this string.
Definition: string.hxx:1505
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1289
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:677
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1582
sal_Int32 indexOf(sal_Char ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: string.hxx:1082
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:492
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:889
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:141
char sal_Char
A legacy synonym for char.
Definition: types.h:120
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1481
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:509
SAL_DLLPUBLIC void rtl_string_ensureCapacity(rtl_String **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, sal_Char oldChar, sal_Char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
libreoffice_internal::ConstCharArrayDetector< T, OString & >::Type operator=(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:328
sal_Int32 indexOf(const OString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: string.hxx:1134
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:799
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1012
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:474
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:602
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1461
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1030
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:350
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:606
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:1147
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const sal_Char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
~OString()
Release the string data.
Definition: string.hxx:287
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
A helper to use OStrings with hash maps.
Definition: string.hxx:1852
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
SAL_DLLPUBLIC void rtl_string_newToAsciiLowerCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
OString(const OString &str)
New string from OString.
Definition: string.hxx:113
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1712
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:250
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: string.hxx:1208
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:1643
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:426
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:230
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:534
sal_Int32 lastIndexOf(const OString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: string.hxx:1231
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:1353
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
sal_Int32 lastIndexOf(sal_Char ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: string.hxx:1097
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1677
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:995
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:1328
SAL_DLLPUBLIC void rtl_uString2String(rtl_String **newStr, const sal_Unicode *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new byte string by converting a Unicode string, using a specific text encoding.
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:164
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:830
unsigned char sal_Bool
Definition: types.h:38
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:387
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1024
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:1622
SAL_DLLPUBLIC void rtl_string_newTrim(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
SAL_WARN_UNUSED_RESULT OString replaceAll(OString const &from, OString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: string.hxx:1377
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:455
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:410
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:956
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:641
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const sal_Char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:950
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:203
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1281
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:645
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1890
__sal_NoAcquire
Definition: types.h:370
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:756
SAL_DLLPUBLIC void rtl_string_newReplaceStrAt(rtl_String **newStr, rtl_String *str, sal_Int32 idx, sal_Int32 count, rtl_String *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
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:1052
Definition: stringutils.hxx:120
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1870
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC void rtl_string_newConcat(rtl_String **newStr, rtl_String *left, rtl_String *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
sal_uInt16 sal_Unicode
Definition: types.h:141
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:1266
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:595
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:874
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1494
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1247
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1537
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
bool equalsIgnoreAsciiCase(const OString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:557
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
static OString number(unsigned long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1628
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1064
SAL_DLLPUBLIC void rtl_string_newReplaceAll(rtl_String **newStr, rtl_String *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(sal_Char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1610
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:297
Definition: bootstrap.hxx:29
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:589
sal_Int32 indexOfL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: string.hxx:1177
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:1308
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:1616
definition of a no acquire enum for ctors
Definition: types.h:374
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:944
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:489
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1569
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1018
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:400
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:665
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:962
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:186
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:925
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1875
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:1412
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1660
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:1395
OString()
New string containing no characters.
Definition: string.hxx:102
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1552
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:973
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
Definition: stringutils.hxx:118
SAL_DLLPUBLIC void rtl_string_newToAsciiUpperCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
OString(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a character buffer array.
Definition: string.hxx:179
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1863
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:1430
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1041
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1520
sal_Int32 lastIndexOf(sal_Char ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: string.hxx:1114
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:1634
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, sal_Char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1595
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:708
SAL_DLLPUBLIC void rtl_string_newFromSubString(rtl_String **newStr, const rtl_String *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
bool matchIgnoreAsciiCase(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: string.hxx:743
size_t operator()(const char *p) const
Definition: string.hxx:1877
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:154
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:92
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:847
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1868
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:785
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1325