LibreOffice
LibreOffice 24.8 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 // coverity[ missing_move_assignment : SUPPRESS] - don't report the suppressed move assignment
192 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
193 {
194 public:
196  rtl_String * pData;
198 
203  {
204  pData = NULL;
205  rtl_string_new( &pData );
206  }
207 
213 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
214  constexpr
215 #endif
216  OString( const OString & str )
217  {
218  pData = str.pData;
219 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
220  if (std::is_constant_evaluated()) {
221  //TODO: We would want to
222  //
223  // assert(SAL_STRING_IS_STATIC(pData));
224  //
225  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
226  // anonymous union with active member `more` is not allowed in a constant expression.
227  } else
228 #endif
229  rtl_string_acquire( pData );
230  }
231 
232 #if defined LIBO_INTERNAL_ONLY
233 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions
234 
240 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
241  constexpr
242 #endif
243  OString( OString && str ) noexcept
244  {
245  pData = str.pData;
246 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
247  if (std::is_constant_evaluated()) {
248  //TODO: We would want to
249  //
250  // assert(SAL_STRING_IS_STATIC(pData));
251  //
252  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
253  // anonymous union with active member `more` is not allowed in a constant expression.
254  return;
255  }
256 #endif
257  str.pData = nullptr;
258  rtl_string_new( &str.pData );
259  }
260 #endif
261 #endif
262 
268  OString( rtl_String * str )
269  {
270  pData = str;
271  rtl_string_acquire( pData );
272  }
273 
281  OString( rtl_String * str, __sal_NoAcquire )
282  {
283  pData = str;
284  }
285 
291  explicit OString( char value )
292  : pData (NULL)
293  {
294  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
295  }
296 
297 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
298  // Catch inadvertent conversions to the above ctor (e.g., from sal_[u]Int8, aka [un]signed
299  // char):
300  OString(int) = delete;
301 #endif
302 
311  template< typename T >
313  {
314  pData = NULL;
315  rtl_string_newFromStr( &pData, value );
316  }
317 
318  template< typename T >
320  {
321  pData = NULL;
322  rtl_string_newFromStr( &pData, value );
323  }
324 
325 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
326  template< typename T >
328  {
329  pData = NULL;
330  rtl_string_newFromStr( &pData, value );
331  }
332 #endif
333 
344  template< typename T >
346  {
347  assert(
349  pData = NULL;
351  rtl_string_new(&pData);
352  } else {
354  &pData,
356  literal),
358  }
359 #ifdef RTL_STRING_UNITTEST
360  rtl_string_unittest_const_literal = true;
361 #endif
362  }
363 
372  OString( const char * value, sal_Int32 length )
373  {
374  pData = NULL;
375  rtl_string_newFromStr_WithLength( &pData, value, length );
376  }
377 
378 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
379 
385  template<std::size_t N> constexpr OString(OStringLiteral<N> const & literal):
386  pData(const_cast<rtl_String *>(&literal.str)) {}
387  template<std::size_t N> OString(OStringLiteral<N> &&) = delete;
389 #endif
390 
391 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
392  // For operator ""_tstr:
393  template<OStringLiteral L> constexpr OString(detail::OStringHolder<L> const & holder):
394  pData(const_cast<rtl_String *>(&holder.literal.str)) {}
395 #endif
396 
397 #if defined LIBO_INTERNAL_ONLY
398  explicit OString(std::string_view sv) {
399  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
400  throw std::bad_alloc();
401  }
402  pData = nullptr;
403  rtl_string_newFromStr_WithLength(&pData, sv.data(), sv.size());
404  }
405 #endif
406 
421  OString( const sal_Unicode * value, sal_Int32 length,
422  rtl_TextEncoding encoding,
423  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
424  {
425  pData = NULL;
426  rtl_uString2String( &pData, value, length, encoding, convertFlags );
427  if (pData == NULL) {
428  throw std::bad_alloc();
429  }
430  }
431 
432 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
433 
437  template< typename T1, typename T2 >
438  OString( OStringConcat< T1, T2 >&& c )
439  {
440  const sal_Int32 l = c.length();
441  pData = rtl_string_alloc( l );
442  if (l != 0)
443  {
444  char* end = c.addData( pData->buffer );
445  pData->length = l;
446  *end = '\0';
447  }
448  }
449 
454  template< std::size_t N >
455  OString( OStringNumber< N >&& n )
456  : OString( n.buf, n.length )
457  {}
458 #endif
459 
460 #ifdef LIBO_INTERNAL_ONLY
461  OString(std::nullptr_t) = delete;
462 #endif
463 
467 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
468  constexpr
469 #endif
471  {
472 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
473  if (std::is_constant_evaluated()) {
474  //TODO: We would want to
475  //
476  // assert(SAL_STRING_IS_STATIC(pData));
477  //
478  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
479  // anonymous union with active member `more` is not allowed in a constant expression.
480  } else
481 #endif
482  rtl_string_release( pData );
483  }
484 
485 #if defined LIBO_INTERNAL_ONLY
486 
497  static OString const & unacquired( rtl_String * const * ppHandle )
498  { return * reinterpret_cast< OString const * >( ppHandle ); }
499 #endif
500 
506  OString & operator=( const OString & str )
507  {
508  rtl_string_assign( &pData, str.pData );
509  return *this;
510  }
511 
512 #if defined LIBO_INTERNAL_ONLY
513 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions
514 
520  OString & operator=( OString && str ) noexcept
521  {
522  rtl_string_release( pData );
523  pData = str.pData;
524  str.pData = nullptr;
525  rtl_string_new( &str.pData );
526  return *this;
527  }
528 #endif
529 #endif
530 
536  template< typename T >
538  {
539  RTL_STRING_CONST_FUNCTION
540  assert(
543  rtl_string_new(&pData);
544  } else {
546  &pData,
548  literal),
550  }
551  return *this;
552  }
553 
559  OString & operator+=( const OString & str )
560 #if defined LIBO_INTERNAL_ONLY
561  &
562 #endif
563  {
564  rtl_string_newConcat( &pData, pData, str.pData );
565  return *this;
566  }
567 #if defined LIBO_INTERNAL_ONLY
568  void operator+=(OString const &) && = delete;
569 #endif
570 
571 #if defined LIBO_INTERNAL_ONLY
573  operator +=(T const & value) & { return operator +=(std::string_view(value)); }
574  template<typename T> typename libreoffice_internal::CharPtrDetector<T, OString &>::Type
575  operator +=(T const &) && = delete;
576 
577  template<typename T>
578  typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type
579  operator +=(T & value) & { return operator +=(std::string_view(value)); }
580  template<typename T>
581  typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type operator +=(T &) &&
582  = delete;
583 
584  template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
585  operator +=(T & literal) & {
586  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
587  return operator +=(
588  std::string_view(
589  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
590  libreoffice_internal::ConstCharArrayDetector<T>::length));
591  }
592  template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
593  operator +=(T &) && = delete;
594 
595  template<std::size_t N> OString & operator +=(OStringLiteral<N> const & literal) &
596  { return operator +=(std::string_view(literal.getStr(), literal.getLength())); }
597  template<std::size_t N> void operator +=(OStringLiteral<N> const &) && = delete;
598 
599  OString & operator +=(std::string_view sv) & {
600  if (sv.empty()) {
601  return *this;
602  }
603  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max() - pData->length)) {
604  throw std::bad_alloc();
605  }
606  auto const l = pData->length + sv.size();
607  rtl_string_ensureCapacity(&pData, l);
608  *addDataHelper(pData->buffer + pData->length, sv.data(), sv.size()) = '\0';
609  pData->length = l;
610  return *this;
611  }
612  void operator +=(std::string_view) && = delete;
613 #endif
614 
615 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
616 
620  template< typename T1, typename T2 >
621  OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
622  sal_Int32 l = c.length();
623  if( l == 0 )
624  return *this;
625  l += pData->length;
626  rtl_string_ensureCapacity( &pData, l );
627  char* end = c.addData( pData->buffer + pData->length );
628  *end = '\0';
629  pData->length = l;
630  return *this;
631  }
632  template<typename T1, typename T2> void operator +=(
633  OStringConcat<T1, T2> &&) && = delete;
634 
639  template< std::size_t N >
640  OString& operator+=( OStringNumber< N >&& n ) & {
641  return operator +=(std::string_view(n.buf, n.length));
642  }
643  template<std::size_t N> void operator +=(
644  OStringNumber<N> &&) && = delete;
645 #endif
646 
651  void clear()
652  {
653  rtl_string_new( &pData );
654  }
655 
664  sal_Int32 getLength() const { return pData->length; }
665 
674  bool isEmpty() const
675  {
676  return pData->length == 0;
677  }
678 
690  const char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
691 
701  char operator [](sal_Int32 index) const {
702  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
703  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
704  return getStr()[index];
705  }
706 
719  sal_Int32 compareTo( const OString & str ) const
720  {
721  return rtl_str_compare_WithLength( pData->buffer, pData->length,
722  str.pData->buffer, str.pData->length );
723  }
724 
738  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
739  {
740  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
741  rObj.pData->buffer, rObj.pData->length, maxLength );
742  }
743 
756  sal_Int32 reverseCompareTo( const OString & str ) const
757  {
758  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
759  str.pData->buffer, str.pData->length );
760  }
761 
773  bool equals( const OString & str ) const
774  {
775  if ( pData->length != str.pData->length )
776  return false;
777  if ( pData == str.pData )
778  return true;
779  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
780  str.pData->buffer, str.pData->length ) == 0;
781  }
782 
797  bool equalsL( const char* value, sal_Int32 length ) const
798  {
799  if ( pData->length != length )
800  return false;
801 
802  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
803  value, length ) == 0;
804  }
805 
820 #if defined LIBO_INTERNAL_ONLY
821  bool equalsIgnoreAsciiCase( std::string_view str ) const
822  {
823  if ( sal_uInt32(pData->length) != str.size() )
824  return false;
825  if ( pData->buffer == str.data() )
826  return true;
827  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
828  str.data(), str.size() ) == 0;
829  }
830 #else
831  bool equalsIgnoreAsciiCase( const OString & str ) const
832  {
833  if ( pData->length != str.pData->length )
834  return false;
835  if ( pData == str.pData )
836  return true;
837  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
838  str.pData->buffer, str.pData->length ) == 0;
839  }
840 #endif
841 
863  template< typename T >
865  {
866  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
867  }
868 
869  template< typename T >
871  {
872  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
873  }
874 
880  template< typename T >
882  {
883  RTL_STRING_CONST_FUNCTION
884  assert(
886  return
887  (pData->length
890  pData->buffer, pData->length,
892  literal),
894  == 0);
895  }
896 
916  bool equalsIgnoreAsciiCaseL( const char * asciiStr, sal_Int32 asciiStrLength ) const
917  {
918  if ( pData->length != asciiStrLength )
919  return false;
920 
921  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
922  asciiStr, asciiStrLength ) == 0;
923  }
924 
940 #if defined LIBO_INTERNAL_ONLY
941  bool match( std::string_view str, sal_Int32 fromIndex = 0 ) const
942  {
943  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
944  str.data(), str.size(), str.size() ) == 0;
945  }
946 #else
947  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
948  {
949  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
950  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
951  }
952 #endif
953 
959  template< typename T >
960  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
961  {
962  RTL_STRING_CONST_FUNCTION
963  assert(
965  return
967  pData->buffer + fromIndex, pData->length - fromIndex,
969  literal),
972  == 0;
973  }
974 
991  bool matchL(
992  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
993  const
994  {
996  pData->buffer + fromIndex, pData->length - fromIndex,
997  str, strLength, strLength) == 0;
998  }
999 
1000  // This overload is left undefined, to detect calls of matchL that
1001  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1002  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1003  // platforms):
1004 #if SAL_TYPES_SIZEOFLONG == 8
1005  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
1006 #endif
1007 
1026 #if defined LIBO_INTERNAL_ONLY
1027  bool matchIgnoreAsciiCase( std::string_view str, sal_Int32 fromIndex = 0 ) const
1028  {
1029  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1030  str.data(), str.size(),
1031  str.size() ) == 0;
1032  }
1033 #else
1034  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
1035  {
1036  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1037  str.pData->buffer, str.pData->length,
1038  str.pData->length ) == 0;
1039  }
1040 #endif
1041 
1046  template< typename T >
1047  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1048  {
1049  RTL_STRING_CONST_FUNCTION
1050  assert(
1052  return
1054  pData->buffer+fromIndex, pData->length-fromIndex,
1056  literal),
1059  == 0;
1060  }
1061 
1076 #if defined LIBO_INTERNAL_ONLY
1077  bool startsWith(std::string_view str, OString * rest = NULL) const {
1078  bool b = match(str);
1079  if (b && rest != NULL) {
1080  *rest = copy(str.size());
1081  }
1082  return b;
1083  }
1084 #else
1085  bool startsWith(OString const & str, OString * rest = NULL) const {
1086  bool b = match(str);
1087  if (b && rest != NULL) {
1088  *rest = copy(str.getLength());
1089  }
1090  return b;
1091  }
1092 #endif
1093 
1099  template< typename T >
1101  T & literal, OString * rest = NULL) const
1102  {
1103  RTL_STRING_CONST_FUNCTION
1104  bool b = match(literal, 0);
1105  if (b && rest != NULL) {
1106  *rest = copy(
1108  }
1109  return b;
1110  }
1111 
1131 #if defined LIBO_INTERNAL_ONLY
1132  bool startsWithIgnoreAsciiCase(std::string_view str, OString * rest = NULL)
1133  const
1134  {
1135  bool b = matchIgnoreAsciiCase(str);
1136  if (b && rest != NULL) {
1137  *rest = copy(str.size());
1138  }
1139  return b;
1140  }
1141 #else
1142  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
1143  const
1144  {
1145  bool b = matchIgnoreAsciiCase(str);
1146  if (b && rest != NULL) {
1147  *rest = copy(str.getLength());
1148  }
1149  return b;
1150  }
1151 #endif
1152 
1158  template< typename T >
1160  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
1161  {
1162  RTL_STRING_CONST_FUNCTION
1163  assert(
1165  bool b = matchIgnoreAsciiCase(literal);
1166  if (b && rest != NULL) {
1167  *rest = copy(
1169  }
1170  return b;
1171  }
1172 
1187 #if defined LIBO_INTERNAL_ONLY
1188  bool endsWith(std::string_view str, OString * rest = NULL) const {
1189  bool b = str.size() <= sal_uInt32(getLength())
1190  && match(str, getLength() - str.size());
1191  if (b && rest != NULL) {
1192  *rest = copy(0, getLength() - str.size());
1193  }
1194  return b;
1195  }
1196 #else
1197  bool endsWith(OString const & str, OString * rest = NULL) const {
1198  bool b = str.getLength() <= getLength()
1199  && match(str, getLength() - str.getLength());
1200  if (b && rest != NULL) {
1201  *rest = copy(0, getLength() - str.getLength());
1202  }
1203  return b;
1204  }
1205 #endif
1206 
1212  template< typename T >
1214  T & literal, OString * rest = NULL) const
1215  {
1216  RTL_STRING_CONST_FUNCTION
1217  assert(
1219  bool b
1221  <= sal_uInt32(getLength()))
1222  && match(
1224  literal),
1225  (getLength()
1227  if (b && rest != NULL) {
1228  *rest = copy(
1229  0,
1230  (getLength()
1232  }
1233  return b;
1234  }
1235 
1249  bool endsWithL(char const * str, sal_Int32 strLength) const {
1250  return strLength <= getLength()
1251  && matchL(str, strLength, getLength() - strLength);
1252  }
1253 
1254  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
1255  { return rStr1.equals(rStr2); }
1256  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
1257  { return !(operator == ( rStr1, rStr2 )); }
1258  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
1259  { return rStr1.compareTo( rStr2 ) < 0; }
1260  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
1261  { return rStr1.compareTo( rStr2 ) > 0; }
1262  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
1263  { return rStr1.compareTo( rStr2 ) <= 0; }
1264  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
1265  { return rStr1.compareTo( rStr2 ) >= 0; }
1266 
1267  template< typename T >
1268  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
1269  {
1270  return
1272  rStr1.getStr(), rStr1.getLength(), value, rtl_str_getLength(value))
1273  == 0;
1274  }
1275 
1276  template< typename T >
1278  {
1279  return
1281  rStr1.getStr(), rStr1.getLength(), value, rtl_str_getLength(value))
1282  == 0;
1283  }
1284 
1285  template< typename T >
1286  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
1287  {
1288  return
1290  value, rtl_str_getLength(value), rStr2.getStr(), rStr2.getLength())
1291  == 0;
1292  }
1293 
1294  template< typename T >
1296  {
1297  return
1299  value, rtl_str_getLength(value), rStr2.getStr(), rStr2.getLength())
1300  == 0;
1301  }
1302 
1308  template< typename T >
1310  {
1311  RTL_STRING_CONST_FUNCTION
1312  assert(
1314  return
1315  (rStr.getLength()
1318  rStr.pData->buffer, rStr.pData->length,
1320  literal),
1322  == 0);
1323  }
1324 
1330  template< typename T >
1332  {
1333  RTL_STRING_CONST_FUNCTION
1334  assert(
1336  return
1337  (rStr.getLength()
1340  rStr.pData->buffer, rStr.pData->length,
1342  literal),
1344  == 0);
1345  }
1346 
1347  template< typename T >
1348  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1349  {
1350  return !(operator == ( rStr1, value ));
1351  }
1352 
1353  template< typename T >
1355  {
1356  return !(operator == ( rStr1, value ));
1357  }
1358 
1359  template< typename T >
1360  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1361  {
1362  return !(operator == ( value, rStr2 ));
1363  }
1364 
1365  template< typename T >
1367  {
1368  return !(operator == ( value, rStr2 ));
1369  }
1370 
1376  template< typename T >
1378  {
1379  return !( rStr == literal );
1380  }
1381 
1387  template< typename T >
1389  {
1390  return !( literal == rStr );
1391  }
1392 
1400  sal_Int32 hashCode() const
1401  {
1402  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1403  }
1404 
1418  sal_Int32 indexOf( char ch, sal_Int32 fromIndex = 0 ) const
1419  {
1420  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1421  return (ret < 0 ? ret : ret+fromIndex);
1422  }
1423 
1433  sal_Int32 lastIndexOf( char ch ) const
1434  {
1435  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1436  }
1437 
1450  sal_Int32 lastIndexOf( char ch, sal_Int32 fromIndex ) const
1451  {
1452  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1453  }
1454 
1470 #if defined LIBO_INTERNAL_ONLY
1471  sal_Int32 indexOf( std::string_view str, sal_Int32 fromIndex = 0 ) const
1472  {
1473  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1474  str.data(), str.size() );
1475  return (ret < 0 ? ret : ret+fromIndex);
1476  }
1477 #else
1478  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1479  {
1480  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1481  str.pData->buffer, str.pData->length );
1482  return (ret < 0 ? ret : ret+fromIndex);
1483  }
1484 #endif
1485 
1490  template< typename T >
1491  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1492  {
1493  RTL_STRING_CONST_FUNCTION
1494  assert(
1496  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1497  pData->buffer + fromIndex, pData->length - fromIndex,
1500  return n < 0 ? n : n + fromIndex;
1501  }
1502 
1521  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1522  const
1523  {
1524  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1525  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1526  return n < 0 ? n : n + fromIndex;
1527  }
1528 
1529  // This overload is left undefined, to detect calls of indexOfL that
1530  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1531  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1532  // platforms):
1533 #if SAL_TYPES_SIZEOFLONG == 8
1534  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1535 #endif
1536 
1552 #if defined LIBO_INTERNAL_ONLY
1553  sal_Int32 lastIndexOf( std::string_view str ) const
1554  {
1555  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1556  str.data(), str.size() );
1557  }
1558 #else
1559  sal_Int32 lastIndexOf( const OString & str ) const
1560  {
1561  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1562  str.pData->buffer, str.pData->length );
1563  }
1564 #endif
1565 
1583 #if defined LIBO_INTERNAL_ONLY
1584  sal_Int32 lastIndexOf( std::string_view str, sal_Int32 fromIndex ) const
1585  {
1586  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1587  str.data(), str.size() );
1588  }
1589 #else
1590  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1591  {
1592  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1593  str.pData->buffer, str.pData->length );
1594  }
1595 #endif
1596 
1607  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1608  {
1609  return copy(beginIndex, getLength() - beginIndex);
1610  }
1611 
1624  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1625  {
1626  rtl_String *pNew = NULL;
1627  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1628  return OString( pNew, SAL_NO_ACQUIRE );
1629  }
1630 
1631 #if defined LIBO_INTERNAL_ONLY
1632 
1642  SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex ) const
1643  {
1644  assert(beginIndex >= 0);
1645  assert(beginIndex <= getLength());
1646  return subView(beginIndex, getLength() - beginIndex);
1647  }
1648 
1661  SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1662  {
1663  assert(beginIndex >= 0);
1664  assert(count >= 0);
1665  assert(beginIndex <= getLength());
1666  assert(count <= getLength() - beginIndex);
1667  return std::string_view(*this).substr(beginIndex, count);
1668  }
1669 #endif
1670 
1671 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1672 
1681  {
1682  rtl_String* pNew = NULL;
1683  rtl_string_newConcat( &pNew, pData, str.pData );
1684  return OString( pNew, SAL_NO_ACQUIRE );
1685  }
1686 #endif
1687 
1688 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1689  friend OString operator+( const OString & str1, const OString & str2 )
1690  {
1691  return str1.concat( str2 );
1692  }
1693 #endif
1694 
1695 // hide this from internal code to avoid ambiguous lookup error
1696 #ifndef LIBO_INTERNAL_ONLY
1697 
1710  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1711  {
1712  rtl_String* pNew = NULL;
1713  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1714  return OString( pNew, SAL_NO_ACQUIRE );
1715  }
1716 #endif
1717 
1718 #ifdef LIBO_INTERNAL_ONLY
1719  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, std::string_view newStr ) const
1720  {
1721  rtl_String* pNew = NULL;
1722  rtl_string_newReplaceStrAt_WithLength ( &pNew, pData, index, count, newStr.data(), newStr.size() );
1723  return OString( pNew, SAL_NO_ACQUIRE );
1724  }
1725 #endif
1726 
1740  SAL_WARN_UNUSED_RESULT OString replace( char oldChar, char newChar ) const
1741  {
1742  rtl_String* pNew = NULL;
1743  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1744  return OString( pNew, SAL_NO_ACQUIRE );
1745  }
1746 
1766  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1767  {
1768  rtl_String * s = NULL;
1769  sal_Int32 i = 0;
1771  &s, pData, from.pData->buffer, from.pData->length,
1772  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1773  return OString(s, SAL_NO_ACQUIRE);
1774  }
1775 
1789  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1790  rtl_String * s = NULL;
1792  &s, pData, from.pData->buffer, from.pData->length,
1793  to.pData->buffer, to.pData->length);
1794  return OString(s, SAL_NO_ACQUIRE);
1795  }
1796 
1808  {
1809  rtl_String* pNew = NULL;
1810  rtl_string_newToAsciiLowerCase( &pNew, pData );
1811  return OString( pNew, SAL_NO_ACQUIRE );
1812  }
1813 
1825  {
1826  rtl_String* pNew = NULL;
1827  rtl_string_newToAsciiUpperCase( &pNew, pData );
1828  return OString( pNew, SAL_NO_ACQUIRE );
1829  }
1830 
1843  {
1844  rtl_String* pNew = NULL;
1845  rtl_string_newTrim( &pNew, pData );
1846  return OString( pNew, SAL_NO_ACQUIRE );
1847  }
1848 
1873  OString getToken( sal_Int32 token, char cTok, sal_Int32& index ) const
1874  {
1875  rtl_String * pNew = NULL;
1876  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1877  return OString( pNew, SAL_NO_ACQUIRE );
1878  }
1879 
1893  OString getToken(sal_Int32 count, char separator) const {
1894  sal_Int32 n = 0;
1895  return getToken(count, separator, n);
1896  }
1897 
1906  bool toBoolean() const
1907  {
1908  return rtl_str_toBoolean( pData->buffer );
1909  }
1910 
1917  char toChar() const
1918  {
1919  return pData->buffer[0];
1920  }
1921 
1932  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1933  {
1934  return rtl_str_toInt32( pData->buffer, radix );
1935  }
1936 
1949  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1950  {
1951  return rtl_str_toUInt32( pData->buffer, radix );
1952  }
1953 
1964  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1965  {
1966  return rtl_str_toInt64( pData->buffer, radix );
1967  }
1968 
1981  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1982  {
1983  return rtl_str_toUInt64( pData->buffer, radix );
1984  }
1985 
1994  float toFloat() const
1995  {
1996  return rtl_str_toFloat( pData->buffer );
1997  }
1998 
2007  double toDouble() const
2008  {
2009  return rtl_str_toDouble( pData->buffer );
2010  }
2011 
2012 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2013 
2014  static auto number( int i, sal_Int16 radix = 10 )
2015  {
2016  return OStringNumber<RTL_STR_MAX_VALUEOFINT32>(rtl_str_valueOfInt32, i, radix);
2017  }
2018  static auto number( long long ll, sal_Int16 radix = 10 )
2019  {
2020  return OStringNumber<RTL_STR_MAX_VALUEOFINT64>(rtl_str_valueOfInt64, ll, radix);
2021  }
2022  static auto number( unsigned long long ll, sal_Int16 radix = 10 )
2023  {
2024  return OStringNumber<RTL_STR_MAX_VALUEOFUINT64>(rtl_str_valueOfUInt64, ll, radix);
2025  }
2026  static auto number( unsigned int i, sal_Int16 radix = 10 )
2027  {
2028  return number( static_cast< unsigned long long >( i ), radix );
2029  }
2030  static auto number( long i, sal_Int16 radix = 10)
2031  {
2032  return number( static_cast< long long >( i ), radix );
2033  }
2034  static auto number( unsigned long i, sal_Int16 radix = 10 )
2035  {
2036  return number( static_cast< unsigned long long >( i ), radix );
2037  }
2038 #else
2039 
2049  static OString number( int i, sal_Int16 radix = 10 )
2050  {
2051  char aBuf[RTL_STR_MAX_VALUEOFINT32];
2052  return OString(aBuf, rtl_str_valueOfInt32(aBuf, i, radix));
2053  }
2056  static OString number( unsigned int i, sal_Int16 radix = 10 )
2057  {
2058  return number( static_cast< unsigned long long >( i ), radix );
2059  }
2062  static OString number( long i, sal_Int16 radix = 10 )
2063  {
2064  return number( static_cast< long long >( i ), radix );
2065  }
2068  static OString number( unsigned long i, sal_Int16 radix = 10 )
2069  {
2070  return number( static_cast< unsigned long long >( i ), radix );
2071  }
2074  static OString number( long long ll, sal_Int16 radix = 10 )
2075  {
2076  char aBuf[RTL_STR_MAX_VALUEOFINT64];
2077  return OString(aBuf, rtl_str_valueOfInt64(aBuf, ll, radix));
2078  }
2081  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
2082  {
2083  char aBuf[RTL_STR_MAX_VALUEOFUINT64];
2084  return OString(aBuf, rtl_str_valueOfUInt64(aBuf, ll, radix));
2085  }
2086 #endif
2087 
2097  static OString number( float f )
2098  {
2099  rtl_String* pNew = NULL;
2100  // Same as rtl::str::valueOfFP, used for rtl_str_valueOfFloat
2102  RTL_STR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2103  NULL, 0, true);
2104  if (pNew == NULL)
2105  throw std::bad_alloc();
2106 
2107  return OString(pNew, SAL_NO_ACQUIRE);
2108  }
2109 
2119  static OString number( double d )
2120  {
2121  rtl_String* pNew = NULL;
2122  // Same as rtl::str::valueOfFP, used for rtl_str_valueOfDouble
2124  RTL_STR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2125  NULL, 0, true);
2126  if (pNew == NULL)
2127  throw std::bad_alloc();
2128 
2129  return OString(pNew, SAL_NO_ACQUIRE);
2130  }
2131 
2132 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2133  static auto boolean(bool b)
2134  {
2135  return OStringNumber<RTL_STR_MAX_VALUEOFBOOLEAN>(rtl_str_valueOfBoolean, b);
2136  }
2137 #else
2138 
2149  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
2150  {
2151  return boolean(b);
2152  }
2153 
2165  static OString boolean( bool b )
2166  {
2167  char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
2168  return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
2169  }
2170 #endif
2171 
2179  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( char c )
2180  {
2181  return OString( &c, 1 );
2182  }
2183 
2194  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2195  {
2196  return number( i, radix );
2197  }
2198 
2209  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2210  {
2211  return number( ll, radix );
2212  }
2213 
2223  SAL_DEPRECATED("use number()") static OString valueOf( float f )
2224  {
2225  return number(f);
2226  }
2227 
2237  SAL_DEPRECATED("use number()") static OString valueOf( double d )
2238  {
2239  return number(d);
2240  }
2241 
2242 #if defined LIBO_INTERNAL_ONLY
2243  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
2244 #endif
2245 
2246 #if defined LIBO_INTERNAL_ONLY
2247  // A wrapper for the first expression in an
2248  //
2249  // OString::Concat(e1) + e2 + ...
2250  //
2251  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
2252  // classes (so something like
2253  //
2254  // OString s = "a" + (b ? std::string_view("c") : std::string_view("dd"));
2255  //
2256  // would not compile):
2257  template<typename T> [[nodiscard]] static
2258  OStringConcat<OStringConcatMarker, T>
2259  Concat(T const & value) { return OStringConcat<OStringConcatMarker, T>(value); }
2260 
2261  // This overload is needed so that an argument of type 'char const[N]' ends up as
2262  // 'OStringConcat<rtl::OStringConcatMarker, char const[N]>' rather than as
2263  // 'OStringConcat<rtl::OStringConcatMarker, char[N]>':
2264  template<typename T, std::size_t N> [[nodiscard]] static
2265  OStringConcat<OStringConcatMarker, T[N]>
2266  Concat(T (& value)[N]) { return OStringConcat<OStringConcatMarker, T[N]>(value); }
2267 #endif
2268 };
2269 
2270 #if defined LIBO_INTERNAL_ONLY
2271 inline bool operator ==(OString const & lhs, StringConcatenation<char> const & rhs)
2272 { return lhs == std::string_view(rhs); }
2273 inline bool operator !=(OString const & lhs, StringConcatenation<char> const & rhs)
2274 { return lhs != std::string_view(rhs); }
2275 inline bool operator ==(StringConcatenation<char> const & lhs, OString const & rhs)
2276 { return std::string_view(lhs) == rhs; }
2277 inline bool operator !=(StringConcatenation<char> const & lhs, OString const & rhs)
2278 { return std::string_view(lhs) != rhs; }
2279 #endif
2280 
2281 /* ======================================================================= */
2282 
2283 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2284 
2288 template<>
2289 struct ToStringHelper< OString >
2290 {
2291  static std::size_t length( const OString& s ) { return s.getLength(); }
2292  char* operator()( char* buffer, const OString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2293 };
2294 
2298 template<std::size_t N>
2299 struct ToStringHelper< OStringLiteral<N> >
2300 {
2301  static constexpr std::size_t length( const OStringLiteral<N>& str ) { return str.getLength(); }
2302  char* operator()( char* buffer, const OStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
2303 };
2304 
2308 template< typename charT, typename traits, typename T1, typename T2 >
2309 inline std::basic_ostream<charT, traits> & operator <<(
2310  std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
2311 {
2312  return stream << OString( std::move(concat) );
2313 }
2314 #endif
2315 
2316 
2323 {
2333  size_t operator()( const OString& rString ) const
2334  { return static_cast<size_t>(rString.hashCode()); }
2335 };
2336 
2339 {
2340  bool operator()( const char* p1, const char* p2) const
2341  { return rtl_str_compare(p1, p2) == 0; }
2342 };
2343 
2346 {
2347  size_t operator()(const char* p) const
2348  { return rtl_str_hashCode(p); }
2349 };
2350 
2351 /* ======================================================================= */
2352 
2359 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
2361  std::basic_ostream<charT, traits> & stream, OString const & rString)
2362 {
2363  return stream << rString.getStr();
2364  // best effort; potentially loses data due to embedded null characters
2365 }
2366 
2367 } /* Namespace */
2368 
2369 #ifdef RTL_STRING_UNITTEST
2370 namespace rtl
2371 {
2372 typedef rtlunittest::OString OString;
2373 }
2374 #undef RTL_STRING_CONST_FUNCTION
2375 #endif
2376 
2377 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2378 using ::rtl::OString;
2379 using ::rtl::OStringChar;
2380 using ::rtl::Concat2View;
2381 using ::rtl::OStringHash;
2382 using ::rtl::OStringLiteral;
2383 #endif
2384 
2385 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
2386 
2387 template<
2388 #if defined RTL_STRING_UNITTEST
2389  rtlunittest::
2390 #endif
2391  OStringLiteral L>
2392 constexpr
2393 #if defined RTL_STRING_UNITTEST
2394  rtlunittest::
2395 #endif
2396  OString
2397 operator ""_ostr() { return L; }
2398 
2399 template<
2400 #if defined RTL_STRING_UNITTEST
2401  rtlunittest::
2402 #endif
2403  OStringLiteral L>
2404 constexpr
2405 #if defined RTL_STRING_UNITTEST
2406 rtlunittest
2407 #else
2408 rtl
2409 #endif
2410 ::detail::OStringHolder<L> operator ""_tstr() {
2411  return
2412 #if defined RTL_STRING_UNITTEST
2413  rtlunittest
2414 #else
2415  rtl
2416 #endif
2417  ::detail::OStringHolder<L>();
2418 }
2419 
2420 #endif
2421 
2423 
2428 #if defined LIBO_INTERNAL_ONLY
2429 namespace std {
2430 
2431 template<>
2432 struct hash<::rtl::OString>
2433 {
2434  std::size_t operator()(::rtl::OString const & s) const
2435  {
2436  if constexpr (sizeof(std::size_t) == 8)
2437  {
2438  // return a hash that uses the full 64-bit range instead of a 32-bit value
2439  size_t n = s.getLength();
2440  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
2441  n = 37 * n + s[i];
2442  return n;
2443  }
2444  else
2445  return std::size_t(s.hashCode());
2446  }
2447 };
2448 
2449 }
2450 
2451 #endif
2452 
2454 #endif // INCLUDED_RTL_STRING_HXX
2455 
2456 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:2007
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:881
#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:1377
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:664
size_t operator()(const char *p) const
Definition: string.hxx:2347
~OString()
Release the string data.
Definition: string.hxx:470
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1964
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:537
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:2068
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:773
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:319
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:1478
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:1309
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:1624
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:216
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:1590
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:1824
#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:797
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:1100
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:2360
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:690
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:1047
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:421
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1893
OString getToken(sal_Int32 token, char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1873
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:1295
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:1268
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1680
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:719
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:677
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:1213
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:756
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:281
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:1981
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:2333
Definition: stringutils.hxx:146
OString(char value)
New string from a single character.
Definition: string.hxx:291
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:492
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:611
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:2322
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:2074
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:870
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:1142
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:831
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:2097
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:1034
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:2119
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:1559
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:1917
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:1932
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:1765
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:1842
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:1789
unsigned char sal_Bool
Definition: types.h:38
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
__sal_NoAcquire
Definition: types.h:370
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:202
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:1607
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:1277
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:2340
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:1388
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:1418
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:1197
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:1160
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:2165
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2345
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:1949
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:864
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:192
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1366
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:651
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:1740
definition of a no acquire enum for ctors
Definition: types.h:374
OString(const char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:372
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1994
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:916
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:312
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:2081
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:1249
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:345
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:2049
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:2338
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:738
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be used.
Definition: types.h:288
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:674
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:1331
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:1348
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:1450
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:1710
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:947
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:268
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:1085
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:1491
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:2056
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:2062
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1906
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:506
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1354
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:559
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:1807
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:1689
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:1433
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:960
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:991
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1360
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1400
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:1286
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:1521