LibreOffice
LibreOffice 24.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 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_RTL_STRING_HXX
25 #define INCLUDED_RTL_STRING_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdlib>
32 #include <limits>
33 #include <new>
34 #include <ostream>
35 #include <utility>
36 #include <string.h>
37 
38 #if defined LIBO_INTERNAL_ONLY
39 #include <algorithm>
40 #include <string_view>
41 #include <type_traits>
42 #endif
43 
44 #include "rtl/math.h"
45 #include "rtl/textenc.h"
46 #include "rtl/string.h"
47 #include "rtl/stringutils.hxx"
48 
49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
50 #include "config_global.h"
51 #include "rtl/stringconcat.hxx"
52 #endif
53 
54 #ifdef RTL_STRING_UNITTEST
55 extern bool rtl_string_unittest_const_literal;
56 extern bool rtl_string_unittest_const_literal_function;
57 #endif
58 
59 // The unittest uses slightly different code to help check that the proper
60 // calls are made. The class is put into a different namespace to make
61 // sure the compiler generates a different (if generating also non-inline)
62 // copy of the function and does not merge them together. The class
63 // is "brought" into the proper rtl namespace by a typedef below.
64 #ifdef RTL_STRING_UNITTEST
65 #define rtl rtlunittest
66 #endif
67 
68 namespace rtl
69 {
70 
72 #ifdef RTL_STRING_UNITTEST
73 #undef rtl
74 // helper macro to make functions appear more readable
75 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
76 #else
77 #define RTL_STRING_CONST_FUNCTION
78 #endif
79 
81 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
82 
89 template<std::size_t N> class SAL_WARN_UNUSED OStringLiteral {
90  static_assert(N != 0);
91  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
92 
93 public:
94 #if HAVE_CPP_CONSTEVAL
95  consteval
96 #else
97  constexpr
98 #endif
99  OStringLiteral(char const (&literal)[N]) {
100  assertLayout();
101  assert(literal[N - 1] == '\0');
102  std::copy_n(literal, N, more.buffer);
103  }
104 
105 #if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1939 && defined _MANAGED)
106 #if HAVE_CPP_CONSTEVAL
107  consteval
108 #else
109  constexpr
110 #endif
111  OStringLiteral(char8_t const (&literal)[N]) {
112  assertLayout();
113  assert(literal[N - 1] == '\0');
114  std::copy_n(literal, N, more.buffer);
115  }
116 #endif
117 
118  constexpr sal_Int32 getLength() const { return more.length; }
119 
120  constexpr char const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
121 
122  constexpr operator std::string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
123 
124 private:
125  static constexpr void assertLayout() {
126  // These static_asserts verifying the layout compatibility with rtl_String cannot be class
127  // member declarations, as offsetof requires a complete type, so defer them to here:
128  static_assert(std::is_standard_layout_v<OStringLiteral>);
129  static_assert(offsetof(OStringLiteral, str.refCount) == offsetof(OStringLiteral, more.refCount));
130  static_assert(offsetof(OStringLiteral, str.length) == offsetof(OStringLiteral, more.length));
131  static_assert(offsetof(OStringLiteral, str.buffer) == offsetof(OStringLiteral, more.buffer));
132  }
133 
134  struct Data {
135  Data() = default;
136 
137  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
138  sal_Int32 length = N - 1;
139  char buffer[N];
140  };
141 
142 public:
143  // (Data members must be public so that OStringLiteral is a structural type that can be used as
144  // a non-type template parameter type for operator ""_ostr and rtl::detail::OStringHolder:)
145  union {
146  rtl_String str;
147  Data more = {};
148  };
149 };
150 
151 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
152 
153 namespace detail {
154 
155 template<OStringLiteral L> struct OStringHolder {
156  static constexpr auto & literal = L;
157 };
158 
159 }
160 
161 #endif
162 
163 #endif
164 
165 /* ======================================================================= */
166 
191 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
192 {
193 public:
195  rtl_String * pData;
197 
202  {
203  pData = NULL;
204  rtl_string_new( &pData );
205  }
206 
212 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
213  constexpr
214 #endif
215  OString( const OString & str )
216  {
217  pData = str.pData;
218 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
219  if (std::is_constant_evaluated()) {
220  //TODO: We would want to
221  //
222  // assert(SAL_STRING_IS_STATIC(pData));
223  //
224  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
225  // anonymous union with active member `more` is not allowed in a constant expression.
226  } else
227 #endif
228  rtl_string_acquire( pData );
229  }
230 
231 #if defined LIBO_INTERNAL_ONLY
232 
238 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
239  constexpr
240 #endif
241  OString( OString && str ) noexcept
242  {
243  pData = str.pData;
244 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
245  if (std::is_constant_evaluated()) {
246  //TODO: We would want to
247  //
248  // assert(SAL_STRING_IS_STATIC(pData));
249  //
250  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
251  // anonymous union with active member `more` is not allowed in a constant expression.
252  return;
253  }
254 #endif
255  str.pData = nullptr;
256  rtl_string_new( &str.pData );
257  }
258 #endif
259 
265  OString( rtl_String * str )
266  {
267  pData = str;
268  rtl_string_acquire( pData );
269  }
270 
278  OString( rtl_String * str, __sal_NoAcquire )
279  {
280  pData = str;
281  }
282 
288  explicit OString( char value )
289  : pData (NULL)
290  {
291  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
292  }
293 
294 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
295  // Catch inadvertent conversions to the above ctor (e.g., from sal_[u]Int8, aka [un]signed
296  // char):
297  OString(int) = delete;
298 #endif
299 
308  template< typename T >
310  {
311  pData = NULL;
312  rtl_string_newFromStr( &pData, value );
313  }
314 
315  template< typename T >
317  {
318  pData = NULL;
319  rtl_string_newFromStr( &pData, value );
320  }
321 
322 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
323  template< typename T >
325  {
326  pData = NULL;
327  rtl_string_newFromStr( &pData, value );
328  }
329 #endif
330 
341  template< typename T >
343  {
344  assert(
346  pData = NULL;
348  rtl_string_new(&pData);
349  } else {
351  &pData,
353  literal),
355  }
356 #ifdef RTL_STRING_UNITTEST
357  rtl_string_unittest_const_literal = true;
358 #endif
359  }
360 
369  OString( const char * value, sal_Int32 length )
370  {
371  pData = NULL;
372  rtl_string_newFromStr_WithLength( &pData, value, length );
373  }
374 
375 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
376 
382  template<std::size_t N> constexpr OString(OStringLiteral<N> const & literal):
383  pData(const_cast<rtl_String *>(&literal.str)) {}
384  template<std::size_t N> OString(OStringLiteral<N> &&) = delete;
386 #endif
387 
388 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
389  // For operator ""_tstr:
390  template<OStringLiteral L> constexpr OString(detail::OStringHolder<L> const & holder):
391  pData(const_cast<rtl_String *>(&holder.literal.str)) {}
392 #endif
393 
394 #if defined LIBO_INTERNAL_ONLY
395  explicit OString(std::string_view sv) {
396  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
397  throw std::bad_alloc();
398  }
399  pData = nullptr;
400  rtl_string_newFromStr_WithLength(&pData, sv.data(), sv.size());
401  }
402 #endif
403 
418  OString( const sal_Unicode * value, sal_Int32 length,
419  rtl_TextEncoding encoding,
420  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
421  {
422  pData = NULL;
423  rtl_uString2String( &pData, value, length, encoding, convertFlags );
424  if (pData == NULL) {
425  throw std::bad_alloc();
426  }
427  }
428 
429 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
430 
434  template< typename T1, typename T2 >
435  OString( OStringConcat< T1, T2 >&& c )
436  {
437  const sal_Int32 l = c.length();
438  pData = rtl_string_alloc( l );
439  if (l != 0)
440  {
441  char* end = c.addData( pData->buffer );
442  pData->length = l;
443  *end = '\0';
444  }
445  }
446 
451  template< std::size_t N >
452  OString( OStringNumber< N >&& n )
453  : OString( n.buf, n.length )
454  {}
455 #endif
456 
457 #ifdef LIBO_INTERNAL_ONLY
458  OString(std::nullptr_t) = delete;
459 #endif
460 
464 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
465  constexpr
466 #endif
468  {
469 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
470  if (std::is_constant_evaluated()) {
471  //TODO: We would want to
472  //
473  // assert(SAL_STRING_IS_STATIC(pData));
474  //
475  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
476  // anonymous union with active member `more` is not allowed in a constant expression.
477  } else
478 #endif
479  rtl_string_release( pData );
480  }
481 
482 #if defined LIBO_INTERNAL_ONLY
483 
494  static OString const & unacquired( rtl_String * const * ppHandle )
495  { return * reinterpret_cast< OString const * >( ppHandle ); }
496 #endif
497 
503  OString & operator=( const OString & str )
504  {
505  rtl_string_assign( &pData, str.pData );
506  return *this;
507  }
508 
509 #if defined LIBO_INTERNAL_ONLY
510 
516  OString & operator=( OString && str ) noexcept
517  {
518  rtl_string_release( pData );
519  pData = str.pData;
520  str.pData = nullptr;
521  rtl_string_new( &str.pData );
522  return *this;
523  }
524 #endif
525 
531  template< typename T >
533  {
534  RTL_STRING_CONST_FUNCTION
535  assert(
538  rtl_string_new(&pData);
539  } else {
541  &pData,
543  literal),
545  }
546  return *this;
547  }
548 
554  OString & operator+=( const OString & str )
555 #if defined LIBO_INTERNAL_ONLY
556  &
557 #endif
558  {
559  rtl_string_newConcat( &pData, pData, str.pData );
560  return *this;
561  }
562 #if defined LIBO_INTERNAL_ONLY
563  void operator+=(OString const &) && = delete;
564 #endif
565 
566 #if defined LIBO_INTERNAL_ONLY
568  operator +=(T const & value) & { return operator +=(std::string_view(value)); }
569  template<typename T> typename libreoffice_internal::CharPtrDetector<T, OString &>::Type
570  operator +=(T const &) && = delete;
571 
572  template<typename T>
573  typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type
574  operator +=(T & value) & { return operator +=(std::string_view(value)); }
575  template<typename T>
576  typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type operator +=(T &) &&
577  = delete;
578 
579  template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
580  operator +=(T & literal) & {
581  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
582  return operator +=(
583  std::string_view(
584  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
585  libreoffice_internal::ConstCharArrayDetector<T>::length));
586  }
587  template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
588  operator +=(T &) && = delete;
589 
590  template<std::size_t N> OString & operator +=(OStringLiteral<N> const & literal) &
591  { return operator +=(std::string_view(literal.getStr(), literal.getLength())); }
592  template<std::size_t N> void operator +=(OStringLiteral<N> const &) && = delete;
593 
594  OString & operator +=(std::string_view sv) & {
595  if (sv.empty()) {
596  return *this;
597  }
598  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max() - pData->length)) {
599  throw std::bad_alloc();
600  }
601  auto const l = pData->length + sv.size();
602  rtl_string_ensureCapacity(&pData, l);
603  *addDataHelper(pData->buffer + pData->length, sv.data(), sv.size()) = '\0';
604  pData->length = l;
605  return *this;
606  }
607  void operator +=(std::string_view) && = delete;
608 #endif
609 
610 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
611 
615  template< typename T1, typename T2 >
616  OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
617  sal_Int32 l = c.length();
618  if( l == 0 )
619  return *this;
620  l += pData->length;
621  rtl_string_ensureCapacity( &pData, l );
622  char* end = c.addData( pData->buffer + pData->length );
623  *end = '\0';
624  pData->length = l;
625  return *this;
626  }
627  template<typename T1, typename T2> void operator +=(
628  OStringConcat<T1, T2> &&) && = delete;
629 
634  template< std::size_t N >
635  OString& operator+=( OStringNumber< N >&& n ) & {
636  return operator +=(std::string_view(n.buf, n.length));
637  }
638  template<std::size_t N> void operator +=(
639  OStringNumber<N> &&) && = delete;
640 #endif
641 
646  void clear()
647  {
648  rtl_string_new( &pData );
649  }
650 
659  sal_Int32 getLength() const { return pData->length; }
660 
669  bool isEmpty() const
670  {
671  return pData->length == 0;
672  }
673 
685  const char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
686 
696  char operator [](sal_Int32 index) const {
697  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
698  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
699  return getStr()[index];
700  }
701 
714  sal_Int32 compareTo( const OString & str ) const
715  {
716  return rtl_str_compare_WithLength( pData->buffer, pData->length,
717  str.pData->buffer, str.pData->length );
718  }
719 
733  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
734  {
735  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
736  rObj.pData->buffer, rObj.pData->length, maxLength );
737  }
738 
751  sal_Int32 reverseCompareTo( const OString & str ) const
752  {
753  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
754  str.pData->buffer, str.pData->length );
755  }
756 
768  bool equals( const OString & str ) const
769  {
770  if ( pData->length != str.pData->length )
771  return false;
772  if ( pData == str.pData )
773  return true;
774  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
775  str.pData->buffer, str.pData->length ) == 0;
776  }
777 
792  bool equalsL( const char* value, sal_Int32 length ) const
793  {
794  if ( pData->length != length )
795  return false;
796 
797  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
798  value, length ) == 0;
799  }
800 
815 #if defined LIBO_INTERNAL_ONLY
816  bool equalsIgnoreAsciiCase( std::string_view str ) const
817  {
818  if ( sal_uInt32(pData->length) != str.size() )
819  return false;
820  if ( pData->buffer == str.data() )
821  return true;
822  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
823  str.data(), str.size() ) == 0;
824  }
825 #else
826  bool equalsIgnoreAsciiCase( const OString & str ) const
827  {
828  if ( pData->length != str.pData->length )
829  return false;
830  if ( pData == str.pData )
831  return true;
832  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
833  str.pData->buffer, str.pData->length ) == 0;
834  }
835 #endif
836 
858  template< typename T >
860  {
861  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
862  }
863 
864  template< typename T >
866  {
867  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
868  }
869 
875  template< typename T >
877  {
878  RTL_STRING_CONST_FUNCTION
879  assert(
881  return
882  (pData->length
885  pData->buffer, pData->length,
887  literal),
889  == 0);
890  }
891 
911  bool equalsIgnoreAsciiCaseL( const char * asciiStr, sal_Int32 asciiStrLength ) const
912  {
913  if ( pData->length != asciiStrLength )
914  return false;
915 
916  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
917  asciiStr, asciiStrLength ) == 0;
918  }
919 
935 #if defined LIBO_INTERNAL_ONLY
936  bool match( std::string_view str, sal_Int32 fromIndex = 0 ) const
937  {
938  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
939  str.data(), str.size(), str.size() ) == 0;
940  }
941 #else
942  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
943  {
944  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
945  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
946  }
947 #endif
948 
954  template< typename T >
955  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
956  {
957  RTL_STRING_CONST_FUNCTION
958  assert(
960  return
962  pData->buffer + fromIndex, pData->length - fromIndex,
964  literal),
967  == 0;
968  }
969 
986  bool matchL(
987  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
988  const
989  {
991  pData->buffer + fromIndex, pData->length - fromIndex,
992  str, strLength, strLength) == 0;
993  }
994 
995  // This overload is left undefined, to detect calls of matchL that
996  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
997  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
998  // platforms):
999 #if SAL_TYPES_SIZEOFLONG == 8
1000  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
1001 #endif
1002 
1021 #if defined LIBO_INTERNAL_ONLY
1022  bool matchIgnoreAsciiCase( std::string_view str, sal_Int32 fromIndex = 0 ) const
1023  {
1024  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1025  str.data(), str.size(),
1026  str.size() ) == 0;
1027  }
1028 #else
1029  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
1030  {
1031  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1032  str.pData->buffer, str.pData->length,
1033  str.pData->length ) == 0;
1034  }
1035 #endif
1036 
1041  template< typename T >
1042  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1043  {
1044  RTL_STRING_CONST_FUNCTION
1045  assert(
1047  return
1049  pData->buffer+fromIndex, pData->length-fromIndex,
1051  literal),
1054  == 0;
1055  }
1056 
1071 #if defined LIBO_INTERNAL_ONLY
1072  bool startsWith(std::string_view str, OString * rest = NULL) const {
1073  bool b = match(str);
1074  if (b && rest != NULL) {
1075  *rest = copy(str.size());
1076  }
1077  return b;
1078  }
1079 #else
1080  bool startsWith(OString const & str, OString * rest = NULL) const {
1081  bool b = match(str);
1082  if (b && rest != NULL) {
1083  *rest = copy(str.getLength());
1084  }
1085  return b;
1086  }
1087 #endif
1088 
1094  template< typename T >
1096  T & literal, OString * rest = NULL) const
1097  {
1098  RTL_STRING_CONST_FUNCTION
1099  bool b = match(literal, 0);
1100  if (b && rest != NULL) {
1101  *rest = copy(
1103  }
1104  return b;
1105  }
1106 
1126 #if defined LIBO_INTERNAL_ONLY
1127  bool startsWithIgnoreAsciiCase(std::string_view str, OString * rest = NULL)
1128  const
1129  {
1130  bool b = matchIgnoreAsciiCase(str);
1131  if (b && rest != NULL) {
1132  *rest = copy(str.size());
1133  }
1134  return b;
1135  }
1136 #else
1137  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
1138  const
1139  {
1140  bool b = matchIgnoreAsciiCase(str);
1141  if (b && rest != NULL) {
1142  *rest = copy(str.getLength());
1143  }
1144  return b;
1145  }
1146 #endif
1147 
1153  template< typename T >
1155  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
1156  {
1157  RTL_STRING_CONST_FUNCTION
1158  assert(
1160  bool b = matchIgnoreAsciiCase(literal);
1161  if (b && rest != NULL) {
1162  *rest = copy(
1164  }
1165  return b;
1166  }
1167 
1182 #if defined LIBO_INTERNAL_ONLY
1183  bool endsWith(std::string_view str, OString * rest = NULL) const {
1184  bool b = str.size() <= sal_uInt32(getLength())
1185  && match(str, getLength() - str.size());
1186  if (b && rest != NULL) {
1187  *rest = copy(0, getLength() - str.size());
1188  }
1189  return b;
1190  }
1191 #else
1192  bool endsWith(OString const & str, OString * rest = NULL) const {
1193  bool b = str.getLength() <= getLength()
1194  && match(str, getLength() - str.getLength());
1195  if (b && rest != NULL) {
1196  *rest = copy(0, getLength() - str.getLength());
1197  }
1198  return b;
1199  }
1200 #endif
1201 
1207  template< typename T >
1209  T & literal, OString * rest = NULL) const
1210  {
1211  RTL_STRING_CONST_FUNCTION
1212  assert(
1214  bool b
1216  <= sal_uInt32(getLength()))
1217  && match(
1219  literal),
1220  (getLength()
1222  if (b && rest != NULL) {
1223  *rest = copy(
1224  0,
1225  (getLength()
1227  }
1228  return b;
1229  }
1230 
1244  bool endsWithL(char const * str, sal_Int32 strLength) const {
1245  return strLength <= getLength()
1246  && matchL(str, strLength, getLength() - strLength);
1247  }
1248 
1249  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
1250  { return rStr1.equals(rStr2); }
1251  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
1252  { return !(operator == ( rStr1, rStr2 )); }
1253  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
1254  { return rStr1.compareTo( rStr2 ) < 0; }
1255  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
1256  { return rStr1.compareTo( rStr2 ) > 0; }
1257  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
1258  { return rStr1.compareTo( rStr2 ) <= 0; }
1259  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
1260  { return rStr1.compareTo( rStr2 ) >= 0; }
1261 
1262  template< typename T >
1263  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
1264  {
1265  return
1267  rStr1.getStr(), rStr1.getLength(), value, rtl_str_getLength(value))
1268  == 0;
1269  }
1270 
1271  template< typename T >
1273  {
1274  return
1276  rStr1.getStr(), rStr1.getLength(), value, rtl_str_getLength(value))
1277  == 0;
1278  }
1279 
1280  template< typename T >
1281  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
1282  {
1283  return
1285  value, rtl_str_getLength(value), rStr2.getStr(), rStr2.getLength())
1286  == 0;
1287  }
1288 
1289  template< typename T >
1291  {
1292  return
1294  value, rtl_str_getLength(value), rStr2.getStr(), rStr2.getLength())
1295  == 0;
1296  }
1297 
1303  template< typename T >
1305  {
1306  RTL_STRING_CONST_FUNCTION
1307  assert(
1309  return
1310  (rStr.getLength()
1313  rStr.pData->buffer, rStr.pData->length,
1315  literal),
1317  == 0);
1318  }
1319 
1325  template< typename T >
1327  {
1328  RTL_STRING_CONST_FUNCTION
1329  assert(
1331  return
1332  (rStr.getLength()
1335  rStr.pData->buffer, rStr.pData->length,
1337  literal),
1339  == 0);
1340  }
1341 
1342  template< typename T >
1343  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1344  {
1345  return !(operator == ( rStr1, value ));
1346  }
1347 
1348  template< typename T >
1350  {
1351  return !(operator == ( rStr1, value ));
1352  }
1353 
1354  template< typename T >
1355  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1356  {
1357  return !(operator == ( value, rStr2 ));
1358  }
1359 
1360  template< typename T >
1362  {
1363  return !(operator == ( value, rStr2 ));
1364  }
1365 
1371  template< typename T >
1373  {
1374  return !( rStr == literal );
1375  }
1376 
1382  template< typename T >
1384  {
1385  return !( literal == rStr );
1386  }
1387 
1395  sal_Int32 hashCode() const
1396  {
1397  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1398  }
1399 
1413  sal_Int32 indexOf( char ch, sal_Int32 fromIndex = 0 ) const
1414  {
1415  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1416  return (ret < 0 ? ret : ret+fromIndex);
1417  }
1418 
1428  sal_Int32 lastIndexOf( char ch ) const
1429  {
1430  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1431  }
1432 
1445  sal_Int32 lastIndexOf( char ch, sal_Int32 fromIndex ) const
1446  {
1447  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1448  }
1449 
1465 #if defined LIBO_INTERNAL_ONLY
1466  sal_Int32 indexOf( std::string_view str, sal_Int32 fromIndex = 0 ) const
1467  {
1468  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1469  str.data(), str.size() );
1470  return (ret < 0 ? ret : ret+fromIndex);
1471  }
1472 #else
1473  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1474  {
1475  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1476  str.pData->buffer, str.pData->length );
1477  return (ret < 0 ? ret : ret+fromIndex);
1478  }
1479 #endif
1480 
1485  template< typename T >
1486  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1487  {
1488  RTL_STRING_CONST_FUNCTION
1489  assert(
1491  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1492  pData->buffer + fromIndex, pData->length - fromIndex,
1495  return n < 0 ? n : n + fromIndex;
1496  }
1497 
1516  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1517  const
1518  {
1519  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1520  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1521  return n < 0 ? n : n + fromIndex;
1522  }
1523 
1524  // This overload is left undefined, to detect calls of indexOfL that
1525  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1526  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1527  // platforms):
1528 #if SAL_TYPES_SIZEOFLONG == 8
1529  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1530 #endif
1531 
1547 #if defined LIBO_INTERNAL_ONLY
1548  sal_Int32 lastIndexOf( std::string_view str ) const
1549  {
1550  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1551  str.data(), str.size() );
1552  }
1553 #else
1554  sal_Int32 lastIndexOf( const OString & str ) const
1555  {
1556  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1557  str.pData->buffer, str.pData->length );
1558  }
1559 #endif
1560 
1578 #if defined LIBO_INTERNAL_ONLY
1579  sal_Int32 lastIndexOf( std::string_view str, sal_Int32 fromIndex ) const
1580  {
1581  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1582  str.data(), str.size() );
1583  }
1584 #else
1585  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1586  {
1587  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1588  str.pData->buffer, str.pData->length );
1589  }
1590 #endif
1591 
1602  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1603  {
1604  return copy(beginIndex, getLength() - beginIndex);
1605  }
1606 
1619  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1620  {
1621  rtl_String *pNew = NULL;
1622  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1623  return OString( pNew, SAL_NO_ACQUIRE );
1624  }
1625 
1626 #if defined LIBO_INTERNAL_ONLY
1627 
1637  SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex ) const
1638  {
1639  assert(beginIndex >= 0);
1640  assert(beginIndex <= getLength());
1641  return subView(beginIndex, getLength() - beginIndex);
1642  }
1643 
1656  SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1657  {
1658  assert(beginIndex >= 0);
1659  assert(count >= 0);
1660  assert(beginIndex <= getLength());
1661  assert(count <= getLength() - beginIndex);
1662  return std::string_view(*this).substr(beginIndex, count);
1663  }
1664 #endif
1665 
1666 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1667 
1676  {
1677  rtl_String* pNew = NULL;
1678  rtl_string_newConcat( &pNew, pData, str.pData );
1679  return OString( pNew, SAL_NO_ACQUIRE );
1680  }
1681 #endif
1682 
1683 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1684  friend OString operator+( const OString & str1, const OString & str2 )
1685  {
1686  return str1.concat( str2 );
1687  }
1688 #endif
1689 
1690 // hide this from internal code to avoid ambiguous lookup error
1691 #ifndef LIBO_INTERNAL_ONLY
1692 
1705  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1706  {
1707  rtl_String* pNew = NULL;
1708  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1709  return OString( pNew, SAL_NO_ACQUIRE );
1710  }
1711 #endif
1712 
1713 #ifdef LIBO_INTERNAL_ONLY
1714  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, std::string_view newStr ) const
1715  {
1716  rtl_String* pNew = NULL;
1717  rtl_string_newReplaceStrAt_WithLength ( &pNew, pData, index, count, newStr.data(), newStr.size() );
1718  return OString( pNew, SAL_NO_ACQUIRE );
1719  }
1720 #endif
1721 
1735  SAL_WARN_UNUSED_RESULT OString replace( char oldChar, char newChar ) const
1736  {
1737  rtl_String* pNew = NULL;
1738  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1739  return OString( pNew, SAL_NO_ACQUIRE );
1740  }
1741 
1761  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1762  {
1763  rtl_String * s = NULL;
1764  sal_Int32 i = 0;
1766  &s, pData, from.pData->buffer, from.pData->length,
1767  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1768  return OString(s, SAL_NO_ACQUIRE);
1769  }
1770 
1784  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1785  rtl_String * s = NULL;
1787  &s, pData, from.pData->buffer, from.pData->length,
1788  to.pData->buffer, to.pData->length);
1789  return OString(s, SAL_NO_ACQUIRE);
1790  }
1791 
1803  {
1804  rtl_String* pNew = NULL;
1805  rtl_string_newToAsciiLowerCase( &pNew, pData );
1806  return OString( pNew, SAL_NO_ACQUIRE );
1807  }
1808 
1820  {
1821  rtl_String* pNew = NULL;
1822  rtl_string_newToAsciiUpperCase( &pNew, pData );
1823  return OString( pNew, SAL_NO_ACQUIRE );
1824  }
1825 
1838  {
1839  rtl_String* pNew = NULL;
1840  rtl_string_newTrim( &pNew, pData );
1841  return OString( pNew, SAL_NO_ACQUIRE );
1842  }
1843 
1868  OString getToken( sal_Int32 token, char cTok, sal_Int32& index ) const
1869  {
1870  rtl_String * pNew = NULL;
1871  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1872  return OString( pNew, SAL_NO_ACQUIRE );
1873  }
1874 
1888  OString getToken(sal_Int32 count, char separator) const {
1889  sal_Int32 n = 0;
1890  return getToken(count, separator, n);
1891  }
1892 
1901  bool toBoolean() const
1902  {
1903  return rtl_str_toBoolean( pData->buffer );
1904  }
1905 
1912  char toChar() const
1913  {
1914  return pData->buffer[0];
1915  }
1916 
1927  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1928  {
1929  return rtl_str_toInt32( pData->buffer, radix );
1930  }
1931 
1944  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1945  {
1946  return rtl_str_toUInt32( pData->buffer, radix );
1947  }
1948 
1959  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1960  {
1961  return rtl_str_toInt64( pData->buffer, radix );
1962  }
1963 
1976  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1977  {
1978  return rtl_str_toUInt64( pData->buffer, radix );
1979  }
1980 
1989  float toFloat() const
1990  {
1991  return rtl_str_toFloat( pData->buffer );
1992  }
1993 
2002  double toDouble() const
2003  {
2004  return rtl_str_toDouble( pData->buffer );
2005  }
2006 
2007 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2008 
2009  static auto number( int i, sal_Int16 radix = 10 )
2010  {
2011  return OStringNumber<RTL_STR_MAX_VALUEOFINT32>(rtl_str_valueOfInt32, i, radix);
2012  }
2013  static auto number( long long ll, sal_Int16 radix = 10 )
2014  {
2015  return OStringNumber<RTL_STR_MAX_VALUEOFINT64>(rtl_str_valueOfInt64, ll, radix);
2016  }
2017  static auto number( unsigned long long ll, sal_Int16 radix = 10 )
2018  {
2019  return OStringNumber<RTL_STR_MAX_VALUEOFUINT64>(rtl_str_valueOfUInt64, ll, radix);
2020  }
2021  static auto number( unsigned int i, sal_Int16 radix = 10 )
2022  {
2023  return number( static_cast< unsigned long long >( i ), radix );
2024  }
2025  static auto number( long i, sal_Int16 radix = 10)
2026  {
2027  return number( static_cast< long long >( i ), radix );
2028  }
2029  static auto number( unsigned long i, sal_Int16 radix = 10 )
2030  {
2031  return number( static_cast< unsigned long long >( i ), radix );
2032  }
2033 #else
2034 
2044  static OString number( int i, sal_Int16 radix = 10 )
2045  {
2046  char aBuf[RTL_STR_MAX_VALUEOFINT32];
2047  return OString(aBuf, rtl_str_valueOfInt32(aBuf, i, radix));
2048  }
2051  static OString number( unsigned int i, sal_Int16 radix = 10 )
2052  {
2053  return number( static_cast< unsigned long long >( i ), radix );
2054  }
2057  static OString number( long i, sal_Int16 radix = 10 )
2058  {
2059  return number( static_cast< long long >( i ), radix );
2060  }
2063  static OString number( unsigned long i, sal_Int16 radix = 10 )
2064  {
2065  return number( static_cast< unsigned long long >( i ), radix );
2066  }
2069  static OString number( long long ll, sal_Int16 radix = 10 )
2070  {
2071  char aBuf[RTL_STR_MAX_VALUEOFINT64];
2072  return OString(aBuf, rtl_str_valueOfInt64(aBuf, ll, radix));
2073  }
2076  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
2077  {
2078  char aBuf[RTL_STR_MAX_VALUEOFUINT64];
2079  return OString(aBuf, rtl_str_valueOfUInt64(aBuf, ll, radix));
2080  }
2081 #endif
2082 
2092  static OString number( float f )
2093  {
2094  rtl_String* pNew = NULL;
2095  // Same as rtl::str::valueOfFP, used for rtl_str_valueOfFloat
2097  RTL_STR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2098  NULL, 0, true);
2099  if (pNew == NULL)
2100  throw std::bad_alloc();
2101 
2102  return OString(pNew, SAL_NO_ACQUIRE);
2103  }
2104 
2114  static OString number( double d )
2115  {
2116  rtl_String* pNew = NULL;
2117  // Same as rtl::str::valueOfFP, used for rtl_str_valueOfDouble
2119  RTL_STR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2120  NULL, 0, true);
2121  if (pNew == NULL)
2122  throw std::bad_alloc();
2123 
2124  return OString(pNew, SAL_NO_ACQUIRE);
2125  }
2126 
2127 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2128  static auto boolean(bool b)
2129  {
2130  return OStringNumber<RTL_STR_MAX_VALUEOFBOOLEAN>(rtl_str_valueOfBoolean, b);
2131  }
2132 #else
2133 
2144  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
2145  {
2146  return boolean(b);
2147  }
2148 
2160  static OString boolean( bool b )
2161  {
2162  char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
2163  return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
2164  }
2165 #endif
2166 
2174  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( char c )
2175  {
2176  return OString( &c, 1 );
2177  }
2178 
2189  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2190  {
2191  return number( i, radix );
2192  }
2193 
2204  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2205  {
2206  return number( ll, radix );
2207  }
2208 
2218  SAL_DEPRECATED("use number()") static OString valueOf( float f )
2219  {
2220  return number(f);
2221  }
2222 
2232  SAL_DEPRECATED("use number()") static OString valueOf( double d )
2233  {
2234  return number(d);
2235  }
2236 
2237 #if defined LIBO_INTERNAL_ONLY
2238  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
2239 #endif
2240 
2241 #if defined LIBO_INTERNAL_ONLY
2242  // A wrapper for the first expression in an
2243  //
2244  // OString::Concat(e1) + e2 + ...
2245  //
2246  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
2247  // classes (so something like
2248  //
2249  // OString s = "a" + (b ? std::string_view("c") : std::string_view("dd"));
2250  //
2251  // would not compile):
2252  template<typename T> [[nodiscard]] static
2253  OStringConcat<OStringConcatMarker, T>
2254  Concat(T const & value) { return OStringConcat<OStringConcatMarker, T>(value); }
2255 
2256  // This overload is needed so that an argument of type 'char const[N]' ends up as
2257  // 'OStringConcat<rtl::OStringConcatMarker, char const[N]>' rather than as
2258  // 'OStringConcat<rtl::OStringConcatMarker, char[N]>':
2259  template<typename T, std::size_t N> [[nodiscard]] static
2260  OStringConcat<OStringConcatMarker, T[N]>
2261  Concat(T (& value)[N]) { return OStringConcat<OStringConcatMarker, T[N]>(value); }
2262 #endif
2263 };
2264 
2265 #if defined LIBO_INTERNAL_ONLY
2266 inline bool operator ==(OString const & lhs, StringConcatenation<char> const & rhs)
2267 { return lhs == std::string_view(rhs); }
2268 inline bool operator !=(OString const & lhs, StringConcatenation<char> const & rhs)
2269 { return lhs != std::string_view(rhs); }
2270 inline bool operator ==(StringConcatenation<char> const & lhs, OString const & rhs)
2271 { return std::string_view(lhs) == rhs; }
2272 inline bool operator !=(StringConcatenation<char> const & lhs, OString const & rhs)
2273 { return std::string_view(lhs) != rhs; }
2274 #endif
2275 
2276 /* ======================================================================= */
2277 
2278 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2279 
2283 template<>
2284 struct ToStringHelper< OString >
2285 {
2286  static std::size_t length( const OString& s ) { return s.getLength(); }
2287  char* operator()( char* buffer, const OString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2288 };
2289 
2293 template<std::size_t N>
2294 struct ToStringHelper< OStringLiteral<N> >
2295 {
2296  static constexpr std::size_t length( const OStringLiteral<N>& str ) { return str.getLength(); }
2297  char* operator()( char* buffer, const OStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
2298 };
2299 
2303 template< typename charT, typename traits, typename T1, typename T2 >
2304 inline std::basic_ostream<charT, traits> & operator <<(
2305  std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
2306 {
2307  return stream << OString( std::move(concat) );
2308 }
2309 #endif
2310 
2311 
2318 {
2328  size_t operator()( const OString& rString ) const
2329  { return static_cast<size_t>(rString.hashCode()); }
2330 };
2331 
2334 {
2335  bool operator()( const char* p1, const char* p2) const
2336  { return rtl_str_compare(p1, p2) == 0; }
2337 };
2338 
2341 {
2342  size_t operator()(const char* p) const
2343  { return rtl_str_hashCode(p); }
2344 };
2345 
2346 /* ======================================================================= */
2347 
2354 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
2356  std::basic_ostream<charT, traits> & stream, OString const & rString)
2357 {
2358  return stream << rString.getStr();
2359  // best effort; potentially loses data due to embedded null characters
2360 }
2361 
2362 } /* Namespace */
2363 
2364 #ifdef RTL_STRING_UNITTEST
2365 namespace rtl
2366 {
2367 typedef rtlunittest::OString OString;
2368 }
2369 #undef RTL_STRING_CONST_FUNCTION
2370 #endif
2371 
2372 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2373 using ::rtl::OString;
2374 using ::rtl::OStringChar;
2375 using ::rtl::Concat2View;
2376 using ::rtl::OStringHash;
2377 using ::rtl::OStringLiteral;
2378 #endif
2379 
2380 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
2381 
2382 template<
2383 #if defined RTL_STRING_UNITTEST
2384  rtlunittest::
2385 #endif
2386  OStringLiteral L>
2387 constexpr
2388 #if defined RTL_STRING_UNITTEST
2389  rtlunittest::
2390 #endif
2391  OString
2392 operator ""_ostr() { return L; }
2393 
2394 template<
2395 #if defined RTL_STRING_UNITTEST
2396  rtlunittest::
2397 #endif
2398  OStringLiteral L>
2399 constexpr
2400 #if defined RTL_STRING_UNITTEST
2401 rtlunittest
2402 #else
2403 rtl
2404 #endif
2405 ::detail::OStringHolder<L> operator ""_tstr() {
2406  return
2407 #if defined RTL_STRING_UNITTEST
2408  rtlunittest
2409 #else
2410  rtl
2411 #endif
2412  ::detail::OStringHolder<L>();
2413 }
2414 
2415 #endif
2416 
2418 
2423 #if defined LIBO_INTERNAL_ONLY
2424 namespace std {
2425 
2426 template<>
2427 struct hash<::rtl::OString>
2428 {
2429  std::size_t operator()(::rtl::OString const & s) const
2430  {
2431  if constexpr (sizeof(std::size_t) == 8)
2432  {
2433  // return a hash that uses the full 64-bit range instead of a 32-bit value
2434  size_t n = s.getLength();
2435  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
2436  n = 37 * n + s[i];
2437  return n;
2438  }
2439  else
2440  return std::size_t(s.hashCode());
2441  }
2442 };
2443 
2444 }
2445 
2446 #endif
2447 
2449 #endif // INCLUDED_RTL_STRING_HXX
2450 
2451 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:2002
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 ...
Definition: string.hxx:876
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
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 ...
Definition: string.hxx:1372
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:659
size_t operator()(const char *p) const
Definition: string.hxx:2342
~OString()
Release the string data.
Definition: string.hxx:467
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1959
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:631
libreoffice_internal::ConstCharArrayDetector< T, OString &>::Type operator=(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: string.hxx:532
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:2063
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:768
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:316
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
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:1473
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 ...
Definition: string.hxx:1304
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:1619
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:696
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:677
OString(const OString &str)
New string from OString.
Definition: string.hxx:215
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:1585
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:1819
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
bool equalsL(const char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:792
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 ...
Definition: string.hxx:1095
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:2355
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:685
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 ...
Definition: string.hxx:1042
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:418
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1888
OString getToken(sal_Int32 token, char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1868
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:1290
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:1263
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1675
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:714
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:675
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
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 ...
Definition: string.hxx:1208
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:751
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:278
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...
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1976
SAL_DLLPUBLIC double rtl_str_toDouble(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:2328
Definition: stringutils.hxx:146
OString(char value)
New string from a single character.
Definition: string.hxx:288
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:474
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
A helper to use OStrings with hash maps.
Definition: string.hxx:2317
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.
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:2069
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:865
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:1137
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:826
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:2092
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:1029
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:2114
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:1554
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.
char toChar() const
Returns the first character from this string.
Definition: string.hxx:1912
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_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:715
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1927
sal_uInt16 sal_Unicode
Definition: types.h:123
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
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:1760
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:1837
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:1784
unsigned char sal_Bool
Definition: types.h:38
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
__sal_NoAcquire
Definition: types.h:352
Like sprintf() G, &#39;F&#39; or &#39;E&#39; format is used depending on which one is more compact.
Definition: math.h:53
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const 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_math_doubleToString(rtl_String **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
OString()
New string containing no characters.
Definition: string.hxx:201
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1602
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:1272
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:2335
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
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 ...
Definition: string.hxx:1383
sal_Int32 indexOf(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:1413
Definition: bootstrap.hxx:33
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:1192
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
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 ...
Definition: string.hxx:1155
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.
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:2160
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2340
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_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1944
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:859
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:191
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1361
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:646
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_WARN_UNUSED_RESULT OString replace(char oldChar, char newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: string.hxx:1735
definition of a no acquire enum for ctors
Definition: types.h:356
OString(const char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:369
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1989
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
bool equalsIgnoreAsciiCaseL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:911
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
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:309
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
Definition: stringutils.hxx:148
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:2076
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:1244
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:342
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:2044
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.
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2333
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:733
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:669
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 ...
Definition: string.hxx:1326
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_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(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 OString &rStr1, const T &value)
Definition: string.hxx:1343
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
sal_Int32 lastIndexOf(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:1445
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
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:1705
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:942
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:265
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:1080
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 ...
Definition: string.hxx:1486
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:2051
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
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:2057
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1901
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:503
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1349
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:554
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:1802
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, char oldChar, char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
SAL_DLLPUBLIC float rtl_str_toFloat(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1684
sal_Int32 lastIndexOf(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:1428
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 ...
Definition: string.hxx:955
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:986
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1355
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1395
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:1281
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
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...
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:1516