LibreOffice
LibreOffice 5.1 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 <config_global.h>
37 #include <rtl/stringconcat.hxx>
38 #endif
39 
40 #include <sal/log.hxx>
41 
42 // The unittest uses slightly different code to help check that the proper
43 // calls are made. The class is put into a different namespace to make
44 // sure the compiler generates a different (if generating also non-inline)
45 // copy of the function and does not merge them together. The class
46 // is "brought" into the proper rtl namespace by a typedef below.
47 #ifdef RTL_STRING_UNITTEST
48 #define rtl rtlunittest
49 #endif
50 
51 namespace rtl
52 {
53 
55 #ifdef RTL_STRING_UNITTEST
56 #undef rtl
57 // helper macro to make functions appear more readable
58 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
59 #else
60 #define RTL_STRING_CONST_FUNCTION
61 #endif
62 
64 /* ======================================================================= */
65 
90 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
91 {
92 public:
94  rtl_String * pData;
96 
101  {
102  pData = NULL;
103  rtl_string_new( &pData );
104  }
105 
111  OString( const OString & str )
112  {
113  pData = str.pData;
114  rtl_string_acquire( pData );
115  }
116 
122  OString( rtl_String * str )
123  {
124  pData = str;
125  rtl_string_acquire( pData );
126  }
127 
135  inline OString( rtl_String * str, __sal_NoAcquire )
136  {
137  pData = str;
138  }
139 
145  explicit OString( sal_Char value )
146  : pData (NULL)
147  {
148  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
149  }
150 
159  template< typename T >
161  {
162  pData = NULL;
163  rtl_string_newFromStr( &pData, value );
164  }
165 
166  template< typename T >
168  {
169  pData = NULL;
170  rtl_string_newFromStr( &pData, value );
171  }
172 
183  template< typename T >
185  {
186  assert(
188  pData = NULL;
190  rtl_string_new(&pData);
191  } else {
193  &pData,
195  literal),
197  }
198 #ifdef RTL_STRING_UNITTEST
199  rtl_string_unittest_const_literal = true;
200 #endif
201  }
202 
211  OString( const sal_Char * value, sal_Int32 length )
212  {
213  pData = NULL;
214  rtl_string_newFromStr_WithLength( &pData, value, length );
215  }
216 
231  OString( const sal_Unicode * value, sal_Int32 length,
232  rtl_TextEncoding encoding,
233  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
234  {
235  pData = NULL;
236  rtl_uString2String( &pData, value, length, encoding, convertFlags );
237  if (pData == NULL) {
238  throw std::bad_alloc();
239  }
240  }
241 
242 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
243 
247  template< typename T1, typename T2 >
248  OString( const OStringConcat< T1, T2 >& c )
249  {
250  const sal_Int32 l = c.length();
251  pData = rtl_string_alloc( l );
252  if (l != 0)
253  {
254  char* end = c.addData( pData->buffer );
255  pData->length = l;
256  *end = '\0';
257  }
258  }
259 #endif
260 
261 #ifdef LIBO_INTERNAL_ONLY
262  OString(std::nullptr_t) = delete;
263 #endif
264 
269  {
270  rtl_string_release( pData );
271  }
272 
278  OString & operator=( const OString & str )
279  {
280  rtl_string_assign( &pData, str.pData );
281  return *this;
282  }
283 
289  template< typename T >
291  {
292  RTL_STRING_CONST_FUNCTION
293  assert(
296  rtl_string_new(&pData);
297  } else {
299  &pData,
301  literal),
303  }
304  return *this;
305  }
306 
312  OString & operator+=( const OString & str )
313 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
314  &
315 #endif
316  {
317  rtl_string_newConcat( &pData, pData, str.pData );
318  return *this;
319  }
320 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
321  void operator+=(OString const &) && = delete;
322 #endif
323 
324 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
325 
329  template< typename T1, typename T2 >
330  OString& operator+=( const OStringConcat< T1, T2 >& c )
331 #if HAVE_CXX11_REF_QUALIFIER
332  &
333 #endif
334  {
335  sal_Int32 l = c.length();
336  if( l == 0 )
337  return *this;
338  l += pData->length;
339  rtl_string_ensureCapacity( &pData, l );
340  char* end = c.addData( pData->buffer + pData->length );
341  *end = '\0';
342  pData->length = l;
343  return *this;
344  }
345 #if HAVE_CXX11_REF_QUALIFIER
346  template<typename T1, typename T2> void operator +=(
347  OStringConcat<T1, T2> const &) && = delete;
348 #endif
349 #endif
350 
355  void clear()
356  {
357  rtl_string_new( &pData );
358  }
359 
368  sal_Int32 getLength() const { return pData->length; }
369 
378  bool isEmpty() const
379  {
380  return pData->length == 0;
381  }
382 
394  const sal_Char * getStr() const { return pData->buffer; }
395 
405  sal_Char operator [](sal_Int32 index) const {
406  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
407  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
408  return getStr()[index];
409  }
410 
423  sal_Int32 compareTo( const OString & str ) const
424  {
425  return rtl_str_compare_WithLength( pData->buffer, pData->length,
426  str.pData->buffer, str.pData->length );
427  }
428 
442  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
443  {
444  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
445  rObj.pData->buffer, rObj.pData->length, maxLength );
446  }
447 
460  sal_Int32 reverseCompareTo( const OString & str ) const
461  {
462  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
463  str.pData->buffer, str.pData->length );
464  }
465 
477  bool equals( const OString & str ) const
478  {
479  if ( pData->length != str.pData->length )
480  return false;
481  if ( pData == str.pData )
482  return true;
483  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
484  str.pData->buffer, str.pData->length ) == 0;
485  }
486 
502  bool equalsL( const sal_Char* value, sal_Int32 length ) const
503  {
504  if ( pData->length != length )
505  return false;
506 
507  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
508  value, length ) == 0;
509  }
510 
525  bool equalsIgnoreAsciiCase( const OString & str ) const
526  {
527  if ( pData->length != str.pData->length )
528  return false;
529  if ( pData == str.pData )
530  return true;
531  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
532  str.pData->buffer, str.pData->length ) == 0;
533  }
534 
556  template< typename T >
558  {
559  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
560  }
561 
562  template< typename T >
564  {
565  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
566  }
567 
573  template< typename T >
575  {
576  RTL_STRING_CONST_FUNCTION
577  assert(
579  return
580  (pData->length
583  pData->buffer, pData->length,
585  literal),
587  == 0);
588  }
589 
609  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
610  {
611  if ( pData->length != asciiStrLength )
612  return false;
613 
614  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
615  asciiStr, asciiStrLength ) == 0;
616  }
617 
633  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
634  {
635  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
636  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
637  }
638 
644  template< typename T >
645  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
646  {
647  RTL_STRING_CONST_FUNCTION
648  assert(
650  return
652  pData->buffer + fromIndex, pData->length - fromIndex,
654  literal),
657  == 0;
658  }
659 
676  bool matchL(
677  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
678  const
679  {
681  pData->buffer + fromIndex, pData->length - fromIndex,
682  str, strLength, strLength) == 0;
683  }
684 
685  // This overload is left undefined, to detect calls of matchL that
686  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
687  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
688  // platforms):
689 #if SAL_TYPES_SIZEOFLONG == 8
690  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
691 #endif
692 
711  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
712  {
713  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
714  str.pData->buffer, str.pData->length,
715  str.pData->length ) == 0;
716  }
717 
723  template< typename T >
724  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
725  {
726  RTL_STRING_CONST_FUNCTION
727  assert(
729  return
731  pData->buffer+fromIndex, pData->length-fromIndex,
733  literal),
736  == 0;
737  }
738 
753  bool startsWith(OString const & str, OString * rest = NULL) const {
754  bool b = match(str);
755  if (b && rest != NULL) {
756  *rest = copy(str.getLength());
757  }
758  return b;
759  }
760 
766  template< typename T >
768  T & literal, OString * rest = NULL) const
769  {
770  RTL_STRING_CONST_FUNCTION
771  bool b = match(literal, 0);
772  if (b && rest != NULL) {
773  *rest = copy(
775  }
776  return b;
777  }
778 
798  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
799  const
800  {
801  bool b = matchIgnoreAsciiCase(str);
802  if (b && rest != NULL) {
803  *rest = copy(str.getLength());
804  }
805  return b;
806  }
807 
813  template< typename T >
815  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
816  {
817  RTL_STRING_CONST_FUNCTION
818  assert(
820  bool b = matchIgnoreAsciiCase(literal);
821  if (b && rest != NULL) {
822  *rest = copy(
824  }
825  return b;
826  }
827 
842  bool endsWith(OString const & str, OString * rest = NULL) const {
843  bool b = str.getLength() <= getLength()
844  && match(str, getLength() - str.getLength());
845  if (b && rest != NULL) {
846  *rest = copy(0, getLength() - str.getLength());
847  }
848  return b;
849  }
850 
856  template< typename T >
858  T & literal, OString * rest = NULL) const
859  {
860  RTL_STRING_CONST_FUNCTION
861  assert(
863  bool b
865  <= sal_uInt32(getLength()))
866  && match(
868  literal),
869  (getLength()
871  if (b && rest != NULL) {
872  *rest = copy(
873  0,
874  (getLength()
876  }
877  return b;
878  }
879 
893  bool endsWithL(char const * str, sal_Int32 strLength) const {
894  return strLength <= getLength()
895  && matchL(str, strLength, getLength() - strLength);
896  }
897 
898  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
899  { return rStr1.equals(rStr2); }
900  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
901  { return !(operator == ( rStr1, rStr2 )); }
902  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
903  { return rStr1.compareTo( rStr2 ) < 0; }
904  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
905  { return rStr1.compareTo( rStr2 ) > 0; }
906  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
907  { return rStr1.compareTo( rStr2 ) <= 0; }
908  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
909  { return rStr1.compareTo( rStr2 ) >= 0; }
910 
911  template< typename T >
912  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
913  {
914  return rStr1.compareTo( value ) == 0;
915  }
916 
917  template< typename T >
919  {
920  return rStr1.compareTo( value ) == 0;
921  }
922 
923  template< typename T >
924  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
925  {
926  return rStr2.compareTo( value ) == 0;
927  }
928 
929  template< typename T >
931  {
932  return rStr2.compareTo( value ) == 0;
933  }
934 
940  template< typename T >
942  {
943  RTL_STRING_CONST_FUNCTION
944  assert(
946  return
947  (rStr.getLength()
950  rStr.pData->buffer, rStr.pData->length,
952  literal),
954  == 0);
955  }
956 
962  template< typename T >
964  {
965  RTL_STRING_CONST_FUNCTION
966  assert(
968  return
969  (rStr.getLength()
972  rStr.pData->buffer, rStr.pData->length,
974  literal),
976  == 0);
977  }
978 
979  template< typename T >
980  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
981  {
982  return !(operator == ( rStr1, value ));
983  }
984 
985  template< typename T >
987  {
988  return !(operator == ( rStr1, value ));
989  }
990 
991  template< typename T >
992  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
993  {
994  return !(operator == ( value, rStr2 ));
995  }
996 
997  template< typename T >
999  {
1000  return !(operator == ( value, rStr2 ));
1001  }
1002 
1008  template< typename T >
1010  {
1011  return !( rStr == literal );
1012  }
1013 
1019  template< typename T >
1021  {
1022  return !( literal == rStr );
1023  }
1024 
1032  sal_Int32 hashCode() const
1033  {
1034  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1035  }
1036 
1050  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1051  {
1052  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1053  return (ret < 0 ? ret : ret+fromIndex);
1054  }
1055 
1065  sal_Int32 lastIndexOf( sal_Char ch ) const
1066  {
1067  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1068  }
1069 
1082  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1083  {
1084  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1085  }
1086 
1102  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1103  {
1104  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1105  str.pData->buffer, str.pData->length );
1106  return (ret < 0 ? ret : ret+fromIndex);
1107  }
1108 
1114  template< typename T >
1115  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1116  {
1117  RTL_STRING_CONST_FUNCTION
1118  assert(
1120  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1121  pData->buffer + fromIndex, pData->length - fromIndex,
1124  return n < 0 ? n : n + fromIndex;
1125  }
1126 
1145  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1146  const
1147  {
1148  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1149  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1150  return n < 0 ? n : n + fromIndex;
1151  }
1152 
1153  // This overload is left undefined, to detect calls of indexOfL that
1154  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1155  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1156  // platforms):
1157 #if SAL_TYPES_SIZEOFLONG == 8
1158  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1159 #endif
1160 
1176  sal_Int32 lastIndexOf( const OString & str ) const
1177  {
1178  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1179  str.pData->buffer, str.pData->length );
1180  }
1181 
1199  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1200  {
1201  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1202  str.pData->buffer, str.pData->length );
1203  }
1204 
1215  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1216  {
1217  rtl_String *pNew = NULL;
1218  rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1219  return OString( pNew, SAL_NO_ACQUIRE );
1220  }
1221 
1234  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1235  {
1236  rtl_String *pNew = NULL;
1237  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1238  return OString( pNew, SAL_NO_ACQUIRE );
1239  }
1240 
1250  {
1251  rtl_String* pNew = NULL;
1252  rtl_string_newConcat( &pNew, pData, str.pData );
1253  return OString( pNew, SAL_NO_ACQUIRE );
1254  }
1255 
1256 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1257  friend OString operator+( const OString & str1, const OString & str2 )
1258  {
1259  return str1.concat( str2 );
1260  }
1261 #endif
1262 
1276  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1277  {
1278  rtl_String* pNew = NULL;
1279  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1280  return OString( pNew, SAL_NO_ACQUIRE );
1281  }
1282 
1297  {
1298  rtl_String* pNew = NULL;
1299  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1300  return OString( pNew, SAL_NO_ACQUIRE );
1301  }
1302 
1322  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1323  {
1324  rtl_String * s = NULL;
1325  sal_Int32 i = 0;
1327  &s, pData, from.pData->buffer, from.pData->length,
1328  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1329  return OString(s, SAL_NO_ACQUIRE);
1330  }
1331 
1345  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1346  rtl_String * s = NULL;
1348  &s, pData, from.pData->buffer, from.pData->length,
1349  to.pData->buffer, to.pData->length);
1350  return OString(s, SAL_NO_ACQUIRE);
1351  }
1352 
1364  {
1365  rtl_String* pNew = NULL;
1366  rtl_string_newToAsciiLowerCase( &pNew, pData );
1367  return OString( pNew, SAL_NO_ACQUIRE );
1368  }
1369 
1381  {
1382  rtl_String* pNew = NULL;
1383  rtl_string_newToAsciiUpperCase( &pNew, pData );
1384  return OString( pNew, SAL_NO_ACQUIRE );
1385  }
1386 
1399  {
1400  rtl_String* pNew = NULL;
1401  rtl_string_newTrim( &pNew, pData );
1402  return OString( pNew, SAL_NO_ACQUIRE );
1403  }
1404 
1429  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1430  {
1431  rtl_String * pNew = NULL;
1432  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1433  return OString( pNew, SAL_NO_ACQUIRE );
1434  }
1435 
1449  OString getToken(sal_Int32 count, char separator) const {
1450  sal_Int32 n = 0;
1451  return getToken(count, separator, n);
1452  }
1453 
1462  bool toBoolean() const
1463  {
1464  return rtl_str_toBoolean( pData->buffer );
1465  }
1466 
1474  {
1475  return pData->buffer[0];
1476  }
1477 
1488  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1489  {
1490  return rtl_str_toInt32( pData->buffer, radix );
1491  }
1492 
1505  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1506  {
1507  return rtl_str_toUInt32( pData->buffer, radix );
1508  }
1509 
1520  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1521  {
1522  return rtl_str_toInt64( pData->buffer, radix );
1523  }
1524 
1537  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1538  {
1539  return rtl_str_toUInt64( pData->buffer, radix );
1540  }
1541 
1550  float toFloat() const
1551  {
1552  return rtl_str_toFloat( pData->buffer );
1553  }
1554 
1563  double toDouble() const
1564  {
1565  return rtl_str_toDouble( pData->buffer );
1566  }
1567 
1578  static OString number( int i, sal_Int16 radix = 10 )
1579  {
1580  return number( static_cast< long long >( i ), radix );
1581  }
1584  static OString number( unsigned int i, sal_Int16 radix = 10 )
1585  {
1586  return number( static_cast< unsigned long long >( i ), radix );
1587  }
1590  static OString number( long i, sal_Int16 radix = 10 )
1591  {
1592  return number( static_cast< long long >( i ), radix );
1593  }
1596  static OString number( unsigned long i, sal_Int16 radix = 10 )
1597  {
1598  return number( static_cast< unsigned long long >( i ), radix );
1599  }
1602  static OString number( long long ll, sal_Int16 radix = 10 )
1603  {
1605  rtl_String* pNewData = NULL;
1606  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1607  return OString( pNewData, SAL_NO_ACQUIRE );
1608  }
1611  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1612  {
1614  rtl_String* pNewData = NULL;
1615  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1616  return OString( pNewData, SAL_NO_ACQUIRE );
1617  }
1618 
1628  static OString number( float f )
1629  {
1631  rtl_String* pNewData = NULL;
1632  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1633  return OString( pNewData, SAL_NO_ACQUIRE );
1634  }
1635 
1645  static OString number( double d )
1646  {
1648  rtl_String* pNewData = NULL;
1649  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1650  return OString( pNewData, SAL_NO_ACQUIRE );
1651  }
1652 
1664  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1665  {
1666  return boolean(b);
1667  }
1668 
1680  static OString boolean( bool b )
1681  {
1683  rtl_String* pNewData = NULL;
1684  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1685  return OString( pNewData, SAL_NO_ACQUIRE );
1686  }
1687 
1695  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1696  {
1697  return OString( &c, 1 );
1698  }
1699 
1710  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1711  {
1712  return number( i, radix );
1713  }
1714 
1725  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1726  {
1727  return number( ll, radix );
1728  }
1729 
1739  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1740  {
1741  return number(f);
1742  }
1743 
1753  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1754  {
1755  return number(d);
1756  }
1757 
1758 };
1759 
1760 /* ======================================================================= */
1761 
1762 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1763 
1771 struct SAL_WARN_UNUSED OStringLiteral
1772 {
1773  template< int N >
1774  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1775  int size;
1776  const char* data;
1777 };
1778 
1782 template<>
1783 struct ToStringHelper< OString >
1784  {
1785  static int length( const OString& s ) { return s.getLength(); }
1786  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1787  static const bool allowOStringConcat = true;
1788  static const bool allowOUStringConcat = false;
1789  };
1790 
1794 template<>
1795 struct ToStringHelper< OStringLiteral >
1796  {
1797  static int length( const OStringLiteral& str ) { return str.size; }
1798  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1799  static const bool allowOStringConcat = true;
1800  static const bool allowOUStringConcat = false;
1801  };
1802 
1806 template< typename charT, typename traits, typename T1, typename T2 >
1807 inline std::basic_ostream<charT, traits> & operator <<(
1808  std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1809 {
1810  return stream << OString( concat );
1811 }
1812 #endif
1813 
1814 
1821 {
1831  size_t operator()( const OString& rString ) const
1832  { return (size_t)rString.hashCode(); }
1833 };
1834 
1837 {
1838  bool operator()( const char* p1, const char* p2) const
1839  { return rtl_str_compare(p1, p2) == 0; }
1840 };
1841 
1844 {
1845  size_t operator()(const char* p) const
1846  { return rtl_str_hashCode(p); }
1847 };
1848 
1849 /* ======================================================================= */
1850 
1857 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1859  std::basic_ostream<charT, traits> & stream, OString const & string)
1860 {
1861  return stream << string.getStr();
1862  // best effort; potentially loses data due to embedded null characters
1863 }
1864 
1865 } /* Namespace */
1866 
1867 #ifdef RTL_STRING_UNITTEST
1868 namespace rtl
1869 {
1870 typedef rtlunittest::OString OString;
1871 }
1872 #undef RTL_STRING_CONST_FUNCTION
1873 #endif
1874 
1875 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1876 using ::rtl::OString;
1877 using ::rtl::OStringHash;
1878 using ::rtl::OStringLiteral;
1879 #endif
1880 
1881 #endif // INCLUDED_RTL_STRING_HXX
1882 
1883 /* 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:1473
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1257
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:645
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:1550
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:1050
#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:460
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:857
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:122
char sal_Char
A legacy synonym for char.
Definition: types.h:130
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1449
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:477
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:290
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:1102
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:767
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:980
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:442
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:612
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1429
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:998
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:312
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:574
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:1115
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:268
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:1820
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
SAL_DLLPUBLIC void rtl_string_newToAsciiLowerCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
OString(const OString &str)
New string from OString.
Definition: string.hxx:111
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1680
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:231
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:1176
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:1611
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:211
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:502
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:1199
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:1321
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &string)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1858
#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:1065
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1645
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:963
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:1296
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:145
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:798
unsigned char sal_Bool
Definition: types.h:48
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:394
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:355
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:992
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:1590
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:1345
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:423
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:378
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:924
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:609
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:918
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:184
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1249
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:584
__sal_NoAcquire
Definition: types.h:382
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:724
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:323
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:1020
Definition: stringutils.hxx:119
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1838
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC void rtl_string_newConcat(rtl_String **newStr, rtl_String *left, rtl_String *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
sal_uInt16 sal_Unicode
Definition: types.h:155
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1234
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:563
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:842
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1462
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1215
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1505
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:525
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
static OString number(unsigned long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1596
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1032
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:1578
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:278
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:557
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:1145
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:1276
Definition: bootstrap.hxx:29
static OString number(unsigned int i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1584
definition of a no acquire enum for ctors
Definition: types.h:386
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:912
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:499
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:1537
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:986
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:368
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:633
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:930
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:167
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:893
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1843
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:1380
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1628
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:1363
OString()
New string containing no characters.
Definition: string.hxx:100
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1520
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:941
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:117
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:160
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:1831
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:1398
#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:1009
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1488
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:1082
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:1602
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:1563
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:676
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:711
size_t operator()(const char *p) const
Definition: string.hxx:1845
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:135
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:90
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:815
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1836
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:753
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324