1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_RTL_STRING_HXX
25 #define INCLUDED_RTL_STRING_HXX
27 #include "sal/config.h"
38 #if defined LIBO_INTERNAL_ONLY
40 #include <string_view>
41 #include <type_traits>
45 #include "rtl/textenc.h"
46 #include "rtl/string.h"
47 #include "rtl/stringutils.hxx"
49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
50 #include "config_global.h"
51 #include "rtl/stringconcat.hxx"
54 #ifdef RTL_STRING_UNITTEST
55 extern bool rtl_string_unittest_const_literal
;
56 extern bool rtl_string_unittest_const_literal_function
;
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
72 #ifdef RTL_STRING_UNITTEST
74 // helper macro to make functions appear more readable
75 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
77 #define RTL_STRING_CONST_FUNCTION
81 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
84 A wrapper dressing a string literal as a static-refcount rtl_String.
86 This class is not part of public API and is meant to be used only in LibreOffice code.
87 @since LibreOffice 4.0
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");
94 #if HAVE_CPP_CONSTEVAL
99 OStringLiteral(char const (&literal
)[N
]) {
101 assert(literal
[N
- 1] == '\0');
102 std::copy_n(literal
, N
, more
.buffer
);
105 #if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1939 && defined _MANAGED)
106 #if HAVE_CPP_CONSTEVAL
111 OStringLiteral(char8_t
const (&literal
)[N
]) {
113 assert(literal
[N
- 1] == '\0');
114 std::copy_n(literal
, N
, more
.buffer
);
118 constexpr sal_Int32
getLength() const { return more
.length
; }
120 constexpr char const * getStr() const SAL_RETURNS_NONNULL
{ return more
.buffer
; }
122 constexpr operator std::string_view() const { return {more
.buffer
, sal_uInt32(more
.length
)}; }
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
));
137 oslInterlockedCount refCount
= 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
138 sal_Int32 length
= N
- 1;
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:)
151 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
155 template<OStringLiteral L
> struct OStringHolder
{
156 static constexpr auto & literal
= L
;
165 /* ======================================================================= */
168 This String class provide base functionality for C++ like 8-Bit
169 character array handling. The advantage of this class is, that it
170 handle all the memory management for you - and it do it
171 more efficient. If you assign a string to another string, the
172 data of both strings are shared (without any copy operation or
173 memory allocation) as long as you do not change the string. This class
174 stores also the length of the string, so that many operations are
175 faster as the C-str-functions.
177 This class provides only readonly string handling. So you could create
178 a string and you could only query the content from this string.
179 It provides also functionality to change the string, but this results
180 in every case in a new string instance (in the most cases with an
181 memory allocation). You don't have functionality to change the
182 content of the string. If you want to change the string content, then
183 you should use the OStringBuffer class, which provides these
184 functionalities and avoid too much memory allocation.
186 The design of this class is similar to the string classes in Java
187 and so more people should have fewer understanding problems when they
191 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
199 New string containing no characters.
204 rtl_string_new( &pData
);
208 New string from OString.
210 @param str an OString.
212 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
215 OString( const OString
& str
)
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
222 // assert(SAL_STRING_IS_STATIC(pData));
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.
228 rtl_string_acquire( pData
);
231 #if defined LIBO_INTERNAL_ONLY
235 @param str an OString.
236 @since LibreOffice 5.2
238 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
241 OString( OString
&& str
) noexcept
244 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
245 if (std::is_constant_evaluated()) {
246 //TODO: We would want to
248 // assert(SAL_STRING_IS_STATIC(pData));
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.
256 rtl_string_new( &str
.pData
);
261 New string from OString data.
263 @param str an OString data.
265 OString( rtl_String
* str
)
268 rtl_string_acquire( pData
);
271 /** New string from OString data without acquiring it. Takeover of ownership.
273 The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this
274 from other constructors.
276 @param str an OString data.
278 OString( rtl_String
* str
, __sal_NoAcquire
)
284 New string from a single character.
286 @param value a character.
288 explicit OString( char value
)
291 rtl_string_newFromStr_WithLength( &pData
, &value
, 1 );
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
297 OString(int) = delete;
301 New string from a character buffer array.
303 Note: The argument type is always either char* or const char*. The template is
304 used only for technical reasons, as is the second argument.
306 @param value a NULL-terminated character array.
308 template< typename T
>
309 OString( const T
& value
, typename
libreoffice_internal::CharPtrDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy() )
312 rtl_string_newFromStr( &pData
, value
);
315 template< typename T
>
316 OString( T
& value
, typename
libreoffice_internal::NonConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy() )
319 rtl_string_newFromStr( &pData
, value
);
322 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
323 template< typename T
>
324 OString( T
&& value
, typename
libreoffice_internal::NonConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy() )
327 rtl_string_newFromStr( &pData
, value
);
332 New string from a string literal.
334 If there are any embedded \0's in the string literal, the result is undefined.
335 Use the overload that explicitly accepts length.
337 @since LibreOffice 3.6
339 @param literal a string literal
341 template< typename T
>
342 OString( T
& literal
, typename
libreoffice_internal::ConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy() )
345 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
347 if (libreoffice_internal::ConstCharArrayDetector
<T
>::length
== 0) {
348 rtl_string_new(&pData
);
350 rtl_string_newFromLiteral(
352 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
354 libreoffice_internal::ConstCharArrayDetector
<T
>::length
, 0);
356 #ifdef RTL_STRING_UNITTEST
357 rtl_string_unittest_const_literal
= true;
362 New string from a character buffer array.
364 @param value a character array.
365 @param length the number of character which should be copied.
366 The character array length must be greater or
367 equal than this value.
369 OString( const char * value
, sal_Int32 length
)
372 rtl_string_newFromStr_WithLength( &pData
, value
, length
);
375 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
378 New string from an 8-Bit string literal.
380 @since LibreOffice 7.1
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;
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
)) {}
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();
400 rtl_string_newFromStr_WithLength(&pData
, sv
.data(), sv
.size());
405 New string from a Unicode character buffer array.
407 @param value a Unicode character array.
408 @param length the number of character which should be converted.
409 The Unicode character array length must be
410 greater or equal than this value.
411 @param encoding the text encoding in which the Unicode character
412 sequence should be converted.
413 @param convertFlags flags which controls the conversion.
414 see RTL_UNICODETOTEXT_FLAGS_...
416 @exception std::bad_alloc is thrown if an out-of-memory condition occurs
418 OString( const sal_Unicode
* value
, sal_Int32 length
,
419 rtl_TextEncoding encoding
,
420 sal_uInt32 convertFlags
= OUSTRING_TO_OSTRING_CVTFLAGS
)
423 rtl_uString2String( &pData
, value
, length
, encoding
, convertFlags
);
425 throw std::bad_alloc();
429 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
434 template< typename T1
, typename T2
>
435 OString( OStringConcat
< T1
, T2
>&& c
)
437 const sal_Int32 l
= c
.length();
438 pData
= rtl_string_alloc( l
);
441 char* end
= c
.addData( pData
->buffer
);
451 template< std::size_t N
>
452 OString( OStringNumber
< N
>&& n
)
453 : OString( n
.buf
, n
.length
)
457 #ifdef LIBO_INTERNAL_ONLY
458 OString(std::nullptr_t
) = delete;
462 Release the string data.
464 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
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
473 // assert(SAL_STRING_IS_STATIC(pData));
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.
479 rtl_string_release( pData
);
482 #if defined LIBO_INTERNAL_ONLY
483 /** Provides an OString const & passing a storage pointer of an
485 It is more convenient to use C++ OString member functions when dealing
486 with rtl_String * handles. Using this function avoids unnecessary
487 acquire()/release() calls for a temporary OString object.
492 OString const & based on given storage
494 static OString
const & unacquired( rtl_String
* const * ppHandle
)
495 { return * reinterpret_cast< OString
const * >( ppHandle
); }
501 @param str an OString.
503 OString
& operator=( const OString
& str
)
505 rtl_string_assign( &pData
, str
.pData
);
509 #if defined LIBO_INTERNAL_ONLY
511 Move assign a new string.
513 @param str an OString.
514 @since LibreOffice 5.2
516 OString
& operator=( OString
&& str
) noexcept
518 rtl_string_release( pData
);
521 rtl_string_new( &str
.pData
);
528 This function accepts an ASCII string literal as its argument.
529 @since LibreOffice 3.6
531 template< typename T
>
532 typename
libreoffice_internal::ConstCharArrayDetector
< T
, OString
& >::Type
operator=( T
& literal
)
534 RTL_STRING_CONST_FUNCTION
536 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
537 if (libreoffice_internal::ConstCharArrayDetector
<T
>::length
== 0) {
538 rtl_string_new(&pData
);
540 rtl_string_newFromLiteral(
542 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
544 libreoffice_internal::ConstCharArrayDetector
<T
>::length
, 0);
550 Append a string to this string.
552 @param str an OString.
554 OString
& operator+=( const OString
& str
)
555 #if defined LIBO_INTERNAL_ONLY
559 rtl_string_newConcat( &pData
, pData
, str
.pData
);
562 #if defined LIBO_INTERNAL_ONLY
563 void operator+=(OString
const &) && = delete;
566 #if defined LIBO_INTERNAL_ONLY
567 template<typename T
> typename
libreoffice_internal::CharPtrDetector
<T
, OString
&>::Type
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;
573 typename
libreoffice_internal::NonConstCharArrayDetector
<T
, OString
&>::Type
574 operator +=(T
& value
) & { return operator +=(std::string_view(value
)); }
576 typename
libreoffice_internal::NonConstCharArrayDetector
<T
, OString
&>::Type
operator +=(T
&) &&
579 template<typename T
> typename
libreoffice_internal::ConstCharArrayDetector
<T
, OString
&>::Type
580 operator +=(T
& literal
) & {
581 assert(libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
584 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
585 libreoffice_internal::ConstCharArrayDetector
<T
>::length
));
587 template<typename T
> typename
libreoffice_internal::ConstCharArrayDetector
<T
, OString
&>::Type
588 operator +=(T
&) && = delete;
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;
594 OString
& operator +=(std::string_view sv
) & {
598 if (sv
.size() > sal_uInt32(std::numeric_limits
<sal_Int32
>::max() - pData
->length
)) {
599 throw std::bad_alloc();
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';
607 void operator +=(std::string_view
) && = delete;
610 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
615 template< typename T1
, typename T2
>
616 OString
& operator+=( OStringConcat
< T1
, T2
>&& c
) & {
617 sal_Int32 l
= c
.length();
621 rtl_string_ensureCapacity( &pData
, l
);
622 char* end
= c
.addData( pData
->buffer
+ pData
->length
);
627 template<typename T1
, typename T2
> void operator +=(
628 OStringConcat
<T1
, T2
> &&) && = delete;
634 template< std::size_t N
>
635 OString
& operator+=( OStringNumber
< N
>&& n
) & {
636 return operator +=(std::string_view(n
.buf
, n
.length
));
638 template<std::size_t N
> void operator +=(
639 OStringNumber
<N
> &&) && = delete;
643 Clears the string, i.e, makes a zero-character string
644 @since LibreOffice 4.4
648 rtl_string_new( &pData
);
652 Returns the length of this string.
654 The length is equal to the number of characters in this string.
656 @return the length of the sequence of characters represented by this
659 sal_Int32
getLength() const { return pData
->length
; }
662 Checks if a string is empty.
664 @return true if the string is empty;
667 @since LibreOffice 3.4
671 return pData
->length
== 0;
675 Returns a pointer to the characters of this string.
677 <p>The returned pointer is guaranteed to point to a null-terminated byte
678 string. But note that this string object may contain embedded null
679 characters, which will thus also be embedded in the returned
680 null-terminated byte string.</p>
682 @return a pointer to a null-terminated byte string representing the
683 characters of this string object.
685 const char * getStr() const SAL_RETURNS_NONNULL
{ return pData
->buffer
; }
688 Access to individual characters.
690 @param index must be non-negative and less than length.
692 @return the character at the given index.
694 @since LibreOffice 3.5
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
];
703 Compares two strings.
705 The comparison is based on the numeric value of each character in
706 the strings and return a value indicating their relationship.
707 This function can't be used for language specific sorting.
709 @param str the object to be compared.
710 @return 0 - if both strings are equal
711 < 0 - if this string is less than the string argument
712 > 0 - if this string is greater than the string argument
714 sal_Int32
compareTo( const OString
& str
) const
716 return rtl_str_compare_WithLength( pData
->buffer
, pData
->length
,
717 str
.pData
->buffer
, str
.pData
->length
);
721 Compares two strings with an maximum count of characters.
723 The comparison is based on the numeric value of each character in
724 the strings and return a value indicating their relationship.
725 This function can't be used for language specific sorting.
727 @param rObj the object to be compared.
728 @param maxLength the maximum count of characters to be compared.
729 @return 0 - if both strings are equal
730 < 0 - if this string is less than the string argument
731 > 0 - if this string is greater than the string argument
733 sal_Int32
compareTo( const OString
& rObj
, sal_Int32 maxLength
) const
735 return rtl_str_shortenedCompare_WithLength( pData
->buffer
, pData
->length
,
736 rObj
.pData
->buffer
, rObj
.pData
->length
, maxLength
);
740 Compares two strings in reverse order.
742 The comparison is based on the numeric value of each character in
743 the strings and return a value indicating their relationship.
744 This function can't be used for language specific sorting.
746 @param str the object to be compared.
747 @return 0 - if both strings are equal
748 < 0 - if this string is less than the string argument
749 > 0 - if this string is greater than the string argument
751 sal_Int32
reverseCompareTo( const OString
& str
) const
753 return rtl_str_reverseCompare_WithLength( pData
->buffer
, pData
->length
,
754 str
.pData
->buffer
, str
.pData
->length
);
758 Perform a comparison of two strings.
760 The result is true if and only if second string
761 represents the same sequence of characters as the first string.
762 This function can't be used for language specific comparison.
764 @param str the object to be compared.
765 @return true if the strings are equal;
768 bool equals( const OString
& str
) const
770 if ( pData
->length
!= str
.pData
->length
)
772 if ( pData
== str
.pData
)
774 return rtl_str_reverseCompare_WithLength( pData
->buffer
, pData
->length
,
775 str
.pData
->buffer
, str
.pData
->length
) == 0;
779 Perform a comparison of two strings.
781 The result is true if and only if second string
782 represents the same sequence of characters as the first string.
783 The ASCII string must be greater or equal as length.
784 This function can't be used for language specific comparison.
787 @param value a character array.
788 @param length the length of the character array.
789 @return true if the strings are equal;
792 bool equalsL( const char* value
, sal_Int32 length
) const
794 if ( pData
->length
!= length
)
797 return rtl_str_reverseCompare_WithLength( pData
->buffer
, pData
->length
,
798 value
, length
) == 0;
802 Perform an ASCII lowercase comparison of two strings.
804 The result is true if and only if second string
805 represents the same sequence of characters as the first string,
807 Character values between 65 and 90 (ASCII A-Z) are interpreted as
808 values between 97 and 122 (ASCII a-z).
809 This function can't be used for language specific comparison.
811 @param str the object to be compared.
812 @return true if the strings are equal;
815 #if defined LIBO_INTERNAL_ONLY
816 bool equalsIgnoreAsciiCase( std::string_view str
) const
818 if ( sal_uInt32(pData
->length
) != str
.size() )
820 if ( pData
->buffer
== str
.data() )
822 return rtl_str_compareIgnoreAsciiCase_WithLength( pData
->buffer
, pData
->length
,
823 str
.data(), str
.size() ) == 0;
826 bool equalsIgnoreAsciiCase( const OString
& str
) const
828 if ( pData
->length
!= str
.pData
->length
)
830 if ( pData
== str
.pData
)
832 return rtl_str_compareIgnoreAsciiCase_WithLength( pData
->buffer
, pData
->length
,
833 str
.pData
->buffer
, str
.pData
->length
) == 0;
838 Perform an ASCII lowercase comparison of two strings.
840 The result is true if and only if second string
841 represents the same sequence of characters as the first string,
843 Character values between 65 and 90 (ASCII A-Z) are interpreted as
844 values between 97 and 122 (ASCII a-z).
845 Since this method is optimized for performance, the ASCII character
846 values are not converted in any way. The caller has to make sure that
847 all ASCII characters are in the allowed range between 0 and
848 127. The ASCII string must be NULL-terminated.
849 This function can't be used for language specific comparison.
851 Note: The argument type is always either char* or const char*, the return type is bool.
852 The template is used only for technical reasons.
854 @param asciiStr the 8-Bit ASCII character string to be compared.
855 @return true if the strings are equal;
858 template< typename T
>
859 typename
libreoffice_internal::CharPtrDetector
< T
, bool >::Type
equalsIgnoreAsciiCase( const T
& asciiStr
) const
861 return rtl_str_compareIgnoreAsciiCase( pData
->buffer
, asciiStr
) == 0;
864 template< typename T
>
865 typename
libreoffice_internal::NonConstCharArrayDetector
< T
, bool >::Type
equalsIgnoreAsciiCase( T
& asciiStr
) const
867 return rtl_str_compareIgnoreAsciiCase( pData
->buffer
, asciiStr
) == 0;
872 This function accepts an ASCII string literal as its argument.
873 @since LibreOffice 3.6
875 template< typename T
>
876 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
equalsIgnoreAsciiCase( T
& literal
) const
878 RTL_STRING_CONST_FUNCTION
880 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
883 == libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
884 && (rtl_str_compareIgnoreAsciiCase_WithLength(
885 pData
->buffer
, pData
->length
,
886 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
888 libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
893 Perform an ASCII lowercase comparison of two strings.
895 The result is true if and only if second string
896 represents the same sequence of characters as the first string,
898 Character values between 65 and 90 (ASCII A-Z) are interpreted as
899 values between 97 and 122 (ASCII a-z).
900 Since this method is optimized for performance, the ASCII character
901 values are not converted in any way. The caller has to make sure that
902 all ASCII characters are in the allowed range between 0 and
903 127. The ASCII string must be greater or equal in length as asciiStrLength.
904 This function can't be used for language specific comparison.
906 @param asciiStr the 8-Bit ASCII character string to be compared.
907 @param asciiStrLength the length of the ascii string
908 @return true if the strings are equal;
911 bool equalsIgnoreAsciiCaseL( const char * asciiStr
, sal_Int32 asciiStrLength
) const
913 if ( pData
->length
!= asciiStrLength
)
916 return rtl_str_compareIgnoreAsciiCase_WithLength( pData
->buffer
, pData
->length
,
917 asciiStr
, asciiStrLength
) == 0;
921 Match against a substring appearing in this string.
923 The result is true if and only if the second string appears as a substring
924 of this string, at the given position.
925 This function can't be used for language specific comparison.
927 @param str the object (substring) to be compared.
928 @param fromIndex the index to start the comparison from.
929 The index must be greater or equal than 0
930 and less or equal as the string length.
931 @return true if str match with the characters in the string
932 at the given position;
935 #if defined LIBO_INTERNAL_ONLY
936 bool match( std::string_view str
, sal_Int32 fromIndex
= 0 ) const
938 return rtl_str_shortenedCompare_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
939 str
.data(), str
.size(), str
.size() ) == 0;
942 bool match( const OString
& str
, sal_Int32 fromIndex
= 0 ) const
944 return rtl_str_shortenedCompare_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
945 str
.pData
->buffer
, str
.pData
->length
, str
.pData
->length
) == 0;
951 This function accepts an ASCII string literal as its argument.
952 @since LibreOffice 3.6
954 template< typename T
>
955 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
match( T
& literal
, sal_Int32 fromIndex
= 0 ) const
957 RTL_STRING_CONST_FUNCTION
959 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
961 rtl_str_shortenedCompare_WithLength(
962 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
,
963 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
965 libreoffice_internal::ConstCharArrayDetector
<T
>::length
,
966 libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
971 Match against a substring appearing in this string.
973 @param str the substring to be compared; must not be null and must point
974 to memory of at least strLength bytes
976 @param strLength the length of the substring; must be non-negative
978 @param fromIndex the index into this string to start the comparison at;
979 must be non-negative and not greater than this string's length
981 @return true if and only if the given str is contained as a substring of
982 this string at the given fromIndex
984 @since LibreOffice 3.6
987 char const * str
, sal_Int32 strLength
, sal_Int32 fromIndex
= 0)
990 return rtl_str_shortenedCompare_WithLength(
991 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
,
992 str
, strLength
, strLength
) == 0;
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
999 #if SAL_TYPES_SIZEOFLONG == 8
1000 void matchL(char const *, sal_Int32
, rtl_TextEncoding
) const;
1004 Match against a substring appearing in this string, ignoring the case of
1007 The result is true if and only if the second string appears as a substring
1008 of this string, at the given position.
1009 Character values between 65 and 90 (ASCII A-Z) are interpreted as
1010 values between 97 and 122 (ASCII a-z).
1011 This function can't be used for language specific comparison.
1013 @param str the object (substring) to be compared.
1014 @param fromIndex the index to start the comparison from.
1015 The index must be greater or equal than 0
1016 and less or equal as the string length.
1017 @return true if str match with the characters in the string
1018 at the given position;
1021 #if defined LIBO_INTERNAL_ONLY
1022 bool matchIgnoreAsciiCase( std::string_view str
, sal_Int32 fromIndex
= 0 ) const
1024 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
1025 str
.data(), str
.size(),
1029 bool matchIgnoreAsciiCase( const OString
& str
, sal_Int32 fromIndex
= 0 ) const
1031 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
1032 str
.pData
->buffer
, str
.pData
->length
,
1033 str
.pData
->length
) == 0;
1038 This function accepts an ASCII string literal as its argument.
1039 @since LibreOffice 3.6
1041 template< typename T
>
1042 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
matchIgnoreAsciiCase( T
& literal
, sal_Int32 fromIndex
= 0 ) const
1044 RTL_STRING_CONST_FUNCTION
1046 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1048 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
1049 pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
1050 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
1052 libreoffice_internal::ConstCharArrayDetector
<T
>::length
,
1053 libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
1058 Check whether this string starts with a given substring.
1060 @param str the substring to be compared
1062 @param rest if non-null, and this function returns true, then assign a
1063 copy of the remainder of this string to *rest. Available since
1066 @return true if and only if the given str appears as a substring at the
1067 start of this string
1069 @since LibreOffice 4.0
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());
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());
1091 This function accepts an ASCII string literal as its argument.
1092 @since LibreOffice 4.0
1094 template< typename T
>
1095 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
startsWith(
1096 T
& literal
, OString
* rest
= NULL
) const
1098 RTL_STRING_CONST_FUNCTION
1099 bool b
= match(literal
, 0);
1100 if (b
&& rest
!= NULL
) {
1102 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1108 Check whether this string starts with a given string, ignoring the case of
1111 Character values between 65 and 90 (ASCII A-Z) are interpreted as
1112 values between 97 and 122 (ASCII a-z).
1113 This function can't be used for language specific comparison.
1115 @param str the substring to be compared
1117 @param rest if non-null, and this function returns true, then assign a
1118 copy of the remainder of this string to *rest.
1120 @return true if and only if the given str appears as a substring at the
1121 start of this string, ignoring the case of ASCII letters ("A"--"Z" and
1124 @since LibreOffice 5.1
1126 #if defined LIBO_INTERNAL_ONLY
1127 bool startsWithIgnoreAsciiCase(std::string_view str
, OString
* rest
= NULL
)
1130 bool b
= matchIgnoreAsciiCase(str
);
1131 if (b
&& rest
!= NULL
) {
1132 *rest
= copy(str
.size());
1137 bool startsWithIgnoreAsciiCase(OString
const & str
, OString
* rest
= NULL
)
1140 bool b
= matchIgnoreAsciiCase(str
);
1141 if (b
&& rest
!= NULL
) {
1142 *rest
= copy(str
.getLength());
1150 This function accepts an ASCII string literal as its argument.
1151 @since LibreOffice 5.1
1153 template< typename T
>
1154 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
1155 startsWithIgnoreAsciiCase(T
& literal
, OString
* rest
= NULL
) const
1157 RTL_STRING_CONST_FUNCTION
1159 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1160 bool b
= matchIgnoreAsciiCase(literal
);
1161 if (b
&& rest
!= NULL
) {
1163 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1169 Check whether this string ends with a given substring.
1171 @param str the substring to be compared
1173 @param rest if non-null, and this function returns true, then assign a
1174 copy of the remainder of this string to *rest. Available since
1177 @return true if and only if the given str appears as a substring at the
1180 @since LibreOffice 3.6
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());
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());
1204 This function accepts an ASCII string literal as its argument.
1205 @since LibreOffice 3.6
1207 template< typename T
>
1208 typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
endsWith(
1209 T
& literal
, OString
* rest
= NULL
) const
1211 RTL_STRING_CONST_FUNCTION
1213 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1215 = (libreoffice_internal::ConstCharArrayDetector
<T
>::length
1216 <= sal_uInt32(getLength()))
1218 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
1221 - libreoffice_internal::ConstCharArrayDetector
<T
>::length
));
1222 if (b
&& rest
!= NULL
) {
1226 - libreoffice_internal::ConstCharArrayDetector
<T
>::length
));
1232 Check whether this string ends with a given substring.
1234 @param str the substring to be compared; must not be null and must point
1235 to memory of at least strLength bytes
1237 @param strLength the length of the substring; must be non-negative
1239 @return true if and only if the given str appears as a substring at the
1242 @since LibreOffice 3.6
1244 bool endsWithL(char const * str
, sal_Int32 strLength
) const {
1245 return strLength
<= getLength()
1246 && matchL(str
, strLength
, getLength() - strLength
);
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; }
1262 template< typename T
>
1263 friend typename
libreoffice_internal::CharPtrDetector
< T
, bool >::Type
operator==( const OString
& rStr1
, const T
& value
)
1266 rtl_str_compare_WithLength(
1267 rStr1
.getStr(), rStr1
.getLength(), value
, rtl_str_getLength(value
))
1271 template< typename T
>
1272 friend typename
libreoffice_internal::NonConstCharArrayDetector
< T
, bool >::Type
operator==( const OString
& rStr1
, T
& value
)
1275 rtl_str_compare_WithLength(
1276 rStr1
.getStr(), rStr1
.getLength(), value
, rtl_str_getLength(value
))
1280 template< typename T
>
1281 friend typename
libreoffice_internal::CharPtrDetector
< T
, bool >::Type
operator==( const T
& value
, const OString
& rStr2
)
1284 rtl_str_compare_WithLength(
1285 value
, rtl_str_getLength(value
), rStr2
.getStr(), rStr2
.getLength())
1289 template< typename T
>
1290 friend typename
libreoffice_internal::NonConstCharArrayDetector
< T
, bool >::Type
operator==( T
& value
, const OString
& rStr2
)
1293 rtl_str_compare_WithLength(
1294 value
, rtl_str_getLength(value
), rStr2
.getStr(), rStr2
.getLength())
1300 This function accepts an ASCII string literal as its argument.
1301 @since LibreOffice 3.6
1303 template< typename T
>
1304 friend typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
operator==( const OString
& rStr
, T
& literal
)
1306 RTL_STRING_CONST_FUNCTION
1308 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1311 == libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
1312 && (rtl_str_compare_WithLength(
1313 rStr
.pData
->buffer
, rStr
.pData
->length
,
1314 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
1316 libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
1322 This function accepts an ASCII string literal as its argument.
1323 @since LibreOffice 3.6
1325 template< typename T
>
1326 friend typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
operator==( T
& literal
, const OString
& rStr
)
1328 RTL_STRING_CONST_FUNCTION
1330 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1333 == libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
1334 && (rtl_str_compare_WithLength(
1335 rStr
.pData
->buffer
, rStr
.pData
->length
,
1336 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
1338 libreoffice_internal::ConstCharArrayDetector
<T
>::length
)
1342 template< typename T
>
1343 friend typename
libreoffice_internal::CharPtrDetector
< T
, bool >::Type
operator!=( const OString
& rStr1
, const T
& value
)
1345 return !(operator == ( rStr1
, value
));
1348 template< typename T
>
1349 friend typename
libreoffice_internal::NonConstCharArrayDetector
< T
, bool >::Type
operator!=( const OString
& rStr1
, T
& value
)
1351 return !(operator == ( rStr1
, value
));
1354 template< typename T
>
1355 friend typename
libreoffice_internal::CharPtrDetector
< T
, bool >::Type
operator!=( const T
& value
, const OString
& rStr2
)
1357 return !(operator == ( value
, rStr2
));
1360 template< typename T
>
1361 friend typename
libreoffice_internal::NonConstCharArrayDetector
< T
, bool >::Type
operator!=( T
& value
, const OString
& rStr2
)
1363 return !(operator == ( value
, rStr2
));
1368 This function accepts an ASCII string literal as its argument.
1369 @since LibreOffice 3.6
1371 template< typename T
>
1372 friend typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
operator!=( const OString
& rStr
, T
& literal
)
1374 return !( rStr
== literal
);
1379 This function accepts an ASCII string literal as its argument.
1380 @since LibreOffice 3.6
1382 template< typename T
>
1383 friend typename
libreoffice_internal::ConstCharArrayDetector
< T
, bool >::Type
operator!=( T
& literal
, const OString
& rStr
)
1385 return !( literal
== rStr
);
1389 Returns a hashcode for this string.
1391 @return a hash code value for this object.
1393 @see rtl::OStringHash for convenient use of std::unordered_map
1395 sal_Int32
hashCode() const
1397 return rtl_str_hashCode_WithLength( pData
->buffer
, pData
->length
);
1401 Returns the index within this string of the first occurrence of the
1402 specified character, starting the search at the specified index.
1404 @param ch character to be located.
1405 @param fromIndex the index to start the search from.
1406 The index must be greater or equal than 0
1407 and less or equal as the string length.
1408 @return the index of the first occurrence of the character in the
1409 character sequence represented by this string that is
1410 greater than or equal to fromIndex, or
1411 -1 if the character does not occur.
1413 sal_Int32
indexOf( char ch
, sal_Int32 fromIndex
= 0 ) const
1415 sal_Int32 ret
= rtl_str_indexOfChar_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
, ch
);
1416 return (ret
< 0 ? ret
: ret
+fromIndex
);
1420 Returns the index within this string of the last occurrence of the
1421 specified character, searching backward starting at the end.
1423 @param ch character to be located.
1424 @return the index of the last occurrence of the character in the
1425 character sequence represented by this string, or
1426 -1 if the character does not occur.
1428 sal_Int32
lastIndexOf( char ch
) const
1430 return rtl_str_lastIndexOfChar_WithLength( pData
->buffer
, pData
->length
, ch
);
1434 Returns the index within this string of the last occurrence of the
1435 specified character, searching backward starting before the specified
1438 @param ch character to be located.
1439 @param fromIndex the index before which to start the search.
1440 @return the index of the last occurrence of the character in the
1441 character sequence represented by this string that
1442 is less than fromIndex, or -1
1443 if the character does not occur before that point.
1445 sal_Int32
lastIndexOf( char ch
, sal_Int32 fromIndex
) const
1447 return rtl_str_lastIndexOfChar_WithLength( pData
->buffer
, fromIndex
, ch
);
1451 Returns the index within this string of the first occurrence of the
1452 specified substring, starting at the specified index.
1454 If str doesn't include any character, always -1 is
1455 returned. This is also the case, if both strings are empty.
1457 @param str the substring to search for.
1458 @param fromIndex the index to start the search from.
1459 @return If the string argument occurs one or more times as a substring
1460 within this string at the starting index, then the index
1461 of the first character of the first such substring is
1462 returned. If it does not occur as a substring starting
1463 at fromIndex or beyond, -1 is returned.
1465 #if defined LIBO_INTERNAL_ONLY
1466 sal_Int32
indexOf( std::string_view str
, sal_Int32 fromIndex
= 0 ) const
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
);
1473 sal_Int32
indexOf( const OString
& str
, sal_Int32 fromIndex
= 0 ) const
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
);
1482 This function accepts an ASCII string literal as its argument.
1483 @since LibreOffice 3.6
1485 template< typename T
>
1486 typename
libreoffice_internal::ConstCharArrayDetector
< T
, sal_Int32
>::Type
indexOf( T
& literal
, sal_Int32 fromIndex
= 0 ) const
1488 RTL_STRING_CONST_FUNCTION
1490 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1491 sal_Int32 n
= rtl_str_indexOfStr_WithLength(
1492 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
,
1493 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1494 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1495 return n
< 0 ? n
: n
+ fromIndex
;
1499 Returns the index within this string of the first occurrence of the
1500 specified substring, starting at the specified index.
1502 If str doesn't include any character, always -1 is
1503 returned. This is also the case, if both strings are empty.
1505 @param str the substring to search for.
1506 @param len the length of the substring.
1507 @param fromIndex the index to start the search from.
1508 @return If the string argument occurs one or more times as a substring
1509 within this string at the starting index, then the index
1510 of the first character of the first such substring is
1511 returned. If it does not occur as a substring starting
1512 at fromIndex or beyond, -1 is returned.
1514 @since LibreOffice 3.6
1516 sal_Int32
indexOfL(char const * str
, sal_Int32 len
, sal_Int32 fromIndex
= 0)
1519 sal_Int32 n
= rtl_str_indexOfStr_WithLength(
1520 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
, str
, len
);
1521 return n
< 0 ? n
: n
+ fromIndex
;
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
1528 #if SAL_TYPES_SIZEOFLONG == 8
1529 void indexOfL(char const *, sal_Int32
, rtl_TextEncoding
) const;
1533 Returns the index within this string of the last occurrence of
1534 the specified substring, searching backward starting at the end.
1536 The returned index indicates the starting index of the substring
1538 If str doesn't include any character, always -1 is
1539 returned. This is also the case, if both strings are empty.
1541 @param str the substring to search for.
1542 @return If the string argument occurs one or more times as a substring
1543 within this string, then the index of the first character of
1544 the last such substring is returned. If it does not occur as
1545 a substring, -1 is returned.
1547 #if defined LIBO_INTERNAL_ONLY
1548 sal_Int32
lastIndexOf( std::string_view str
) const
1550 return rtl_str_lastIndexOfStr_WithLength( pData
->buffer
, pData
->length
,
1551 str
.data(), str
.size() );
1554 sal_Int32
lastIndexOf( const OString
& str
) const
1556 return rtl_str_lastIndexOfStr_WithLength( pData
->buffer
, pData
->length
,
1557 str
.pData
->buffer
, str
.pData
->length
);
1562 Returns the index within this string of the last occurrence of
1563 the specified substring, searching backward starting before the specified
1566 The returned index indicates the starting index of the substring
1568 If str doesn't include any character, always -1 is
1569 returned. This is also the case, if both strings are empty.
1571 @param str the substring to search for.
1572 @param fromIndex the index before which to start the search.
1573 @return If the string argument occurs one or more times as a substring
1574 within this string before the starting index, then the index
1575 of the first character of the last such substring is
1576 returned. Otherwise, -1 is returned.
1578 #if defined LIBO_INTERNAL_ONLY
1579 sal_Int32
lastIndexOf( std::string_view str
, sal_Int32 fromIndex
) const
1581 return rtl_str_lastIndexOfStr_WithLength( pData
->buffer
, fromIndex
,
1582 str
.data(), str
.size() );
1585 sal_Int32
lastIndexOf( const OString
& str
, sal_Int32 fromIndex
) const
1587 return rtl_str_lastIndexOfStr_WithLength( pData
->buffer
, fromIndex
,
1588 str
.pData
->buffer
, str
.pData
->length
);
1593 Returns a new string that is a substring of this string.
1595 The substring begins at the specified beginIndex. If
1596 beginIndex is negative or be greater than the length of
1597 this string, behaviour is undefined.
1599 @param beginIndex the beginning index, inclusive.
1600 @return the specified substring.
1602 SAL_WARN_UNUSED_RESULT OString
copy( sal_Int32 beginIndex
) const
1604 return copy(beginIndex
, getLength() - beginIndex
);
1608 Returns a new string that is a substring of this string.
1610 The substring begins at the specified beginIndex and contains count
1611 characters. If either beginIndex or count are negative,
1612 or beginIndex + count are greater than the length of this string
1613 then behaviour is undefined.
1615 @param beginIndex the beginning index, inclusive.
1616 @param count the number of characters.
1617 @return the specified substring.
1619 SAL_WARN_UNUSED_RESULT OString
copy( sal_Int32 beginIndex
, sal_Int32 count
) const
1621 rtl_String
*pNew
= NULL
;
1622 rtl_string_newFromSubString( &pNew
, pData
, beginIndex
, count
);
1623 return OString( pNew
, SAL_NO_ACQUIRE
);
1626 #if defined LIBO_INTERNAL_ONLY
1628 Returns a std::string_view that is a view of a substring of this string.
1630 The substring begins at the specified beginIndex. If
1631 beginIndex is negative or be greater than the length of
1632 this string, behaviour is undefined.
1634 @param beginIndex the beginning index, inclusive.
1635 @return the specified substring.
1637 SAL_WARN_UNUSED_RESULT
std::string_view
subView( sal_Int32 beginIndex
) const
1639 assert(beginIndex
>= 0);
1640 assert(beginIndex
<= getLength());
1641 return subView(beginIndex
, getLength() - beginIndex
);
1645 Returns a std::string_view that is a view of a substring of this string.
1647 The substring begins at the specified beginIndex and contains count
1648 characters. If either beginIndex or count are negative,
1649 or beginIndex + count are greater than the length of this string
1650 then behaviour is undefined.
1652 @param beginIndex the beginning index, inclusive.
1653 @param count the number of characters.
1654 @return the specified substring.
1656 SAL_WARN_UNUSED_RESULT
std::string_view
subView( sal_Int32 beginIndex
, sal_Int32 count
) const
1658 assert(beginIndex
>= 0);
1660 assert(beginIndex
<= getLength());
1661 assert(count
<= getLength() - beginIndex
);
1662 return std::string_view(*this).substr(beginIndex
, count
);
1666 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1668 Concatenates the specified string to the end of this string.
1670 @param str the string that is concatenated to the end
1672 @return a string that represents the concatenation of this string
1673 followed by the string argument.
1675 SAL_WARN_UNUSED_RESULT OString
concat( const OString
& str
) const
1677 rtl_String
* pNew
= NULL
;
1678 rtl_string_newConcat( &pNew
, pData
, str
.pData
);
1679 return OString( pNew
, SAL_NO_ACQUIRE
);
1683 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1684 friend OString
operator+( const OString
& str1
, const OString
& str2
)
1686 return str1
.concat( str2
);
1690 // hide this from internal code to avoid ambiguous lookup error
1691 #ifndef LIBO_INTERNAL_ONLY
1693 Returns a new string resulting from replacing n = count characters
1694 from position index in this string with newStr.
1696 @param index the replacing index in str.
1697 The index must be greater or equal as 0 and
1698 less or equal as the length of the string.
1699 @param count the count of characters that will replaced
1700 The count must be greater or equal as 0 and
1701 less or equal as the length of the string minus index.
1702 @param newStr the new substring.
1703 @return the new string.
1705 SAL_WARN_UNUSED_RESULT OString
replaceAt( sal_Int32 index
, sal_Int32 count
, const OString
& newStr
) const
1707 rtl_String
* pNew
= NULL
;
1708 rtl_string_newReplaceStrAt( &pNew
, pData
, index
, count
, newStr
.pData
);
1709 return OString( pNew
, SAL_NO_ACQUIRE
);
1713 #ifdef LIBO_INTERNAL_ONLY
1714 SAL_WARN_UNUSED_RESULT OString
replaceAt( sal_Int32 index
, sal_Int32 count
, std::string_view newStr
) const
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
);
1723 Returns a new string resulting from replacing all occurrences of
1724 oldChar in this string with newChar.
1726 If the character oldChar does not occur in the character sequence
1727 represented by this object, then the string is assigned with
1730 @param oldChar the old character.
1731 @param newChar the new character.
1732 @return a string derived from this string by replacing every
1733 occurrence of oldChar with newChar.
1735 SAL_WARN_UNUSED_RESULT OString
replace( char oldChar
, char newChar
) const
1737 rtl_String
* pNew
= NULL
;
1738 rtl_string_newReplace( &pNew
, pData
, oldChar
, newChar
);
1739 return OString( pNew
, SAL_NO_ACQUIRE
);
1743 Returns a new string resulting from replacing the first occurrence of a
1744 given substring with another substring.
1746 @param from the substring to be replaced
1748 @param to the replacing substring
1750 @param[in,out] index pointer to a start index; if the pointer is
1751 non-null: upon entry to the function, its value is the index into the this
1752 string at which to start searching for the \p from substring, the value
1753 must be non-negative and not greater than this string's length; upon exit
1754 from the function its value is the index into this string at which the
1755 replacement took place or -1 if no replacement took place; if the pointer
1756 is null, searching always starts at index 0
1758 @since LibreOffice 3.6
1760 SAL_WARN_UNUSED_RESULT OString
replaceFirst(
1761 OString
const & from
, OString
const & to
, sal_Int32
* index
= NULL
) const
1763 rtl_String
* s
= NULL
;
1765 rtl_string_newReplaceFirst(
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
);
1772 Returns a new string resulting from replacing all occurrences of a given
1773 substring with another substring.
1775 Replacing subsequent occurrences picks up only after a given replacement.
1776 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1778 @param from the substring to be replaced
1780 @param to the replacing substring
1782 @since LibreOffice 3.6
1784 SAL_WARN_UNUSED_RESULT OString
replaceAll(OString
const & from
, OString
const & to
) const {
1785 rtl_String
* s
= NULL
;
1786 rtl_string_newReplaceAll(
1787 &s
, pData
, from
.pData
->buffer
, from
.pData
->length
,
1788 to
.pData
->buffer
, to
.pData
->length
);
1789 return OString(s
, SAL_NO_ACQUIRE
);
1793 Converts from this string all ASCII uppercase characters (65-90)
1794 to ASCII lowercase characters (97-122).
1796 This function can't be used for language specific conversion.
1797 If the string doesn't contain characters which must be converted,
1798 then the new string is assigned with str.
1800 @return the string, converted to ASCII lowercase.
1802 SAL_WARN_UNUSED_RESULT OString
toAsciiLowerCase() const
1804 rtl_String
* pNew
= NULL
;
1805 rtl_string_newToAsciiLowerCase( &pNew
, pData
);
1806 return OString( pNew
, SAL_NO_ACQUIRE
);
1810 Converts from this string all ASCII lowercase characters (97-122)
1811 to ASCII uppercase characters (65-90).
1813 This function can't be used for language specific conversion.
1814 If the string doesn't contain characters which must be converted,
1815 then the new string is assigned with str.
1817 @return the string, converted to ASCII uppercase.
1819 SAL_WARN_UNUSED_RESULT OString
toAsciiUpperCase() const
1821 rtl_String
* pNew
= NULL
;
1822 rtl_string_newToAsciiUpperCase( &pNew
, pData
);
1823 return OString( pNew
, SAL_NO_ACQUIRE
);
1827 Returns a new string resulting from removing white space from both ends
1830 All characters that have codes less than or equal to
1831 32 (the space character) are considered to be white space.
1832 If the string doesn't contain white spaces at both ends,
1833 then the new string is assigned with str.
1835 @return the string, with white space removed from the front and end.
1837 SAL_WARN_UNUSED_RESULT OString
trim() const
1839 rtl_String
* pNew
= NULL
;
1840 rtl_string_newTrim( &pNew
, pData
);
1841 return OString( pNew
, SAL_NO_ACQUIRE
);
1845 Returns a token in the string.
1848 sal_Int32 nIndex = 0;
1852 OString aToken = aStr.getToken( 0, ';', nIndex );
1855 while ( nIndex >= 0 );
1857 @param token the number of the token to return.
1858 @param cTok the character which separate the tokens.
1859 @param index the position at which the token is searched in the
1861 The index must not be greater than the length of the
1863 This param is set to the position of the
1864 next token or to -1, if it is the last token.
1865 @return the token; if either token or index is negative, an empty token
1866 is returned (and index is set to -1)
1868 OString
getToken( sal_Int32 token
, char cTok
, sal_Int32
& index
) const
1870 rtl_String
* pNew
= NULL
;
1871 index
= rtl_string_getToken( &pNew
, pData
, token
, cTok
, index
);
1872 return OString( pNew
, SAL_NO_ACQUIRE
);
1876 Returns a token from the string.
1878 The same as getToken(sal_Int32, char, sal_Int32 &), but always passing
1879 in 0 as the start index in the third argument.
1881 @param count the number of the token to return, starting with 0
1882 @param separator the character which separates the tokens
1884 @return the given token, or an empty string
1886 @since LibreOffice 3.6
1888 OString
getToken(sal_Int32 count
, char separator
) const {
1890 return getToken(count
, separator
, n
);
1894 Returns the Boolean value from this string.
1896 This function can't be used for language specific conversion.
1898 @return true, if the string is 1 or "True" in any ASCII case.
1899 false in any other case.
1901 bool toBoolean() const
1903 return rtl_str_toBoolean( pData
->buffer
);
1907 Returns the first character from this string.
1909 @return the first character from this string or 0, if this string
1914 return pData
->buffer
[0];
1918 Returns the int32 value from this string.
1920 This function can't be used for language specific conversion.
1922 @param radix the radix (between 2 and 36)
1923 @return the int32 represented from this string.
1924 0 if this string represents no number or one of too large
1927 sal_Int32
toInt32( sal_Int16 radix
= 10 ) const
1929 return rtl_str_toInt32( pData
->buffer
, radix
);
1933 Returns the uint32 value from this string.
1935 This function can't be used for language specific conversion.
1937 @param radix the radix (between 2 and 36)
1938 @return the uint32 represented from this string.
1939 0 if this string represents no number or one of too large
1942 @since LibreOffice 4.2
1944 sal_uInt32
toUInt32( sal_Int16 radix
= 10 ) const
1946 return rtl_str_toUInt32( pData
->buffer
, radix
);
1950 Returns the int64 value from this string.
1952 This function can't be used for language specific conversion.
1954 @param radix the radix (between 2 and 36)
1955 @return the int64 represented from this string.
1956 0 if this string represents no number or one of too large
1959 sal_Int64
toInt64( sal_Int16 radix
= 10 ) const
1961 return rtl_str_toInt64( pData
->buffer
, radix
);
1965 Returns the uint64 value from this string.
1967 This function can't be used for language specific conversion.
1969 @param radix the radix (between 2 and 36)
1970 @return the uint64 represented from this string.
1971 0 if this string represents no number or one of too large
1974 @since LibreOffice 4.1
1976 sal_uInt64
toUInt64( sal_Int16 radix
= 10 ) const
1978 return rtl_str_toUInt64( pData
->buffer
, radix
);
1982 Returns the float value from this string.
1984 This function can't be used for language specific conversion.
1986 @return the float represented from this string.
1987 0.0 if this string represents no number.
1989 float toFloat() const
1991 return rtl_str_toFloat( pData
->buffer
);
1995 Returns the double value from this string.
1997 This function can't be used for language specific conversion.
1999 @return the double represented from this string.
2000 0.0 if this string represents no number.
2002 double toDouble() const
2004 return rtl_str_toDouble( pData
->buffer
);
2007 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2009 static auto number( int i
, sal_Int16 radix
= 10 )
2011 return OStringNumber
<RTL_STR_MAX_VALUEOFINT32
>(rtl_str_valueOfInt32
, i
, radix
);
2013 static auto number( long long ll
, sal_Int16 radix
= 10 )
2015 return OStringNumber
<RTL_STR_MAX_VALUEOFINT64
>(rtl_str_valueOfInt64
, ll
, radix
);
2017 static auto number( unsigned long long ll
, sal_Int16 radix
= 10 )
2019 return OStringNumber
<RTL_STR_MAX_VALUEOFUINT64
>(rtl_str_valueOfUInt64
, ll
, radix
);
2021 static auto number( unsigned int i
, sal_Int16 radix
= 10 )
2023 return number( static_cast< unsigned long long >( i
), radix
);
2025 static auto number( long i
, sal_Int16 radix
= 10)
2027 return number( static_cast< long long >( i
), radix
);
2029 static auto number( unsigned long i
, sal_Int16 radix
= 10 )
2031 return number( static_cast< unsigned long long >( i
), radix
);
2035 Returns the string representation of the integer argument.
2037 This function can't be used for language specific conversion.
2039 @param i an integer value
2040 @param radix the radix (between 2 and 36)
2041 @return a string with the string representation of the argument.
2042 @since LibreOffice 4.1
2044 static OString
number( int i
, sal_Int16 radix
= 10 )
2046 char aBuf
[RTL_STR_MAX_VALUEOFINT32
];
2047 return OString(aBuf
, rtl_str_valueOfInt32(aBuf
, i
, radix
));
2050 /// @since LibreOffice 4.1
2051 static OString
number( unsigned int i
, sal_Int16 radix
= 10 )
2053 return number( static_cast< unsigned long long >( i
), radix
);
2056 /// @since LibreOffice 4.1
2057 static OString
number( long i
, sal_Int16 radix
= 10 )
2059 return number( static_cast< long long >( i
), radix
);
2062 /// @since LibreOffice 4.1
2063 static OString
number( unsigned long i
, sal_Int16 radix
= 10 )
2065 return number( static_cast< unsigned long long >( i
), radix
);
2068 /// @since LibreOffice 4.1
2069 static OString
number( long long ll
, sal_Int16 radix
= 10 )
2071 char aBuf
[RTL_STR_MAX_VALUEOFINT64
];
2072 return OString(aBuf
, rtl_str_valueOfInt64(aBuf
, ll
, radix
));
2075 /// @since LibreOffice 4.1
2076 static OString
number( unsigned long long ll
, sal_Int16 radix
= 10 )
2078 char aBuf
[RTL_STR_MAX_VALUEOFUINT64
];
2079 return OString(aBuf
, rtl_str_valueOfUInt64(aBuf
, ll
, radix
));
2084 Returns the string representation of the float argument.
2086 This function can't be used for language specific conversion.
2089 @return a string with the decimal representation of the argument.
2090 @since LibreOffice 4.1
2092 static OString
number( float f
)
2094 rtl_String
* pNew
= NULL
;
2095 // Same as rtl::str::valueOfFP, used for rtl_str_valueOfFloat
2096 rtl_math_doubleToString(&pNew
, NULL
, 0, f
, rtl_math_StringFormat_G
,
2097 RTL_STR_MAX_VALUEOFFLOAT
- SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2100 throw std::bad_alloc();
2102 return OString(pNew
, SAL_NO_ACQUIRE
);
2106 Returns the string representation of the double argument.
2108 This function can't be used for language specific conversion.
2111 @return a string with the decimal representation of the argument.
2112 @since LibreOffice 4.1
2114 static OString
number( double d
)
2116 rtl_String
* pNew
= NULL
;
2117 // Same as rtl::str::valueOfFP, used for rtl_str_valueOfDouble
2118 rtl_math_doubleToString(&pNew
, NULL
, 0, d
, rtl_math_StringFormat_G
,
2119 RTL_STR_MAX_VALUEOFDOUBLE
- SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
2122 throw std::bad_alloc();
2124 return OString(pNew
, SAL_NO_ACQUIRE
);
2127 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2128 static auto boolean(bool b
)
2130 return OStringNumber
<RTL_STR_MAX_VALUEOFBOOLEAN
>(rtl_str_valueOfBoolean
, b
);
2134 Returns the string representation of the sal_Bool argument.
2136 If the sal_Bool is true, the string "true" is returned.
2137 If the sal_Bool is false, the string "false" is returned.
2138 This function can't be used for language specific conversion.
2140 @param b a sal_Bool.
2141 @return a string with the string representation of the argument.
2142 @deprecated use boolean()
2144 SAL_DEPRECATED("use boolean()") static OString
valueOf( sal_Bool b
)
2150 Returns the string representation of the boolean argument.
2152 If the argument is true, the string "true" is returned.
2153 If the argument is false, the string "false" is returned.
2154 This function can't be used for language specific conversion.
2157 @return a string with the string representation of the argument.
2158 @since LibreOffice 4.1
2160 static OString
boolean( bool b
)
2162 char aBuf
[RTL_STR_MAX_VALUEOFBOOLEAN
];
2163 return OString(aBuf
, rtl_str_valueOfBoolean(aBuf
, b
));
2168 Returns the string representation of the char argument.
2170 @param c a character.
2171 @return a string with the string representation of the argument.
2172 @deprecated use operator, function or constructor taking char or sal_Unicode argument
2174 SAL_DEPRECATED("convert to OString or use directly") static OString
valueOf( char c
)
2176 return OString( &c
, 1 );
2180 Returns the string representation of the int argument.
2182 This function can't be used for language specific conversion.
2185 @param radix the radix (between 2 and 36)
2186 @return a string with the string representation of the argument.
2187 @deprecated use number()
2189 SAL_DEPRECATED("use number()") static OString
valueOf( sal_Int32 i
, sal_Int16 radix
= 10 )
2191 return number( i
, radix
);
2195 Returns the string representation of the long argument.
2197 This function can't be used for language specific conversion.
2200 @param radix the radix (between 2 and 36)
2201 @return a string with the string representation of the argument.
2202 @deprecated use number()
2204 SAL_DEPRECATED("use number()") static OString
valueOf( sal_Int64 ll
, sal_Int16 radix
= 10 )
2206 return number( ll
, radix
);
2210 Returns the string representation of the float argument.
2212 This function can't be used for language specific conversion.
2215 @return a string with the string representation of the argument.
2216 @deprecated use number()
2218 SAL_DEPRECATED("use number()") static OString
valueOf( float f
)
2224 Returns the string representation of the double argument.
2226 This function can't be used for language specific conversion.
2229 @return a string with the string representation of the argument.
2230 @deprecated use number()
2232 SAL_DEPRECATED("use number()") static OString
valueOf( double d
)
2237 #if defined LIBO_INTERNAL_ONLY
2238 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
2241 #if defined LIBO_INTERNAL_ONLY
2242 // A wrapper for the first expression in an
2244 // OString::Concat(e1) + e2 + ...
2246 // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
2247 // classes (so something like
2249 // OString s = "a" + (b ? std::string_view("c") : std::string_view("dd"));
2251 // would not compile):
2252 template<typename T
> [[nodiscard
]] static
2253 OStringConcat
<OStringConcatMarker
, T
>
2254 Concat(T
const & value
) { return OStringConcat
<OStringConcatMarker
, T
>(value
); }
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
); }
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
; }
2276 /* ======================================================================= */
2278 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2284 struct ToStringHelper
< OString
>
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()); }
2293 template<std::size_t N
>
2294 struct ToStringHelper
< OStringLiteral
<N
> >
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() ); }
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
)
2307 return stream
<< OString( std::move(concat
) );
2312 /** A helper to use OStrings with hash maps.
2314 Instances of this class are unary function objects that can be used as
2315 hash function arguments to std::unordered_map and similar constructs.
2319 /** Compute a hash code for a string.
2325 a hash code for the string. This hash code should not be stored
2326 persistently, as its computation may change in later revisions.
2328 size_t operator()( const OString
& rString
) const
2329 { return static_cast<size_t>(rString
.hashCode()); }
2332 /** Equality functor for classic c-strings (i.e., null-terminated char* strings). */
2335 bool operator()( const char* p1
, const char* p2
) const
2336 { return rtl_str_compare(p1
, p2
) == 0; }
2339 /** Hashing functor for classic c-strings (i.e., null-terminated char* strings). */
2342 size_t operator()(const char* p
) const
2343 { return rtl_str_hashCode(p
); }
2346 /* ======================================================================= */
2349 Support for rtl::OString in std::ostream (and thus in
2350 CPPUNIT_ASSERT or SAL_INFO macros, for example).
2352 @since LibreOffice 4.0
2354 template< typename charT
, typename traits
> std::basic_ostream
<charT
, traits
> &
2356 std::basic_ostream
<charT
, traits
> & stream
, OString
const & rString
)
2358 return stream
<< rString
.getStr();
2359 // best effort; potentially loses data due to embedded null characters
2364 #ifdef RTL_STRING_UNITTEST
2367 typedef rtlunittest::OString OString
;
2369 #undef RTL_STRING_CONST_FUNCTION
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
;
2380 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
2383 #if defined RTL_STRING_UNITTEST
2388 #if defined RTL_STRING_UNITTEST
2392 operator ""_ostr() { return L
; }
2395 #if defined RTL_STRING_UNITTEST
2400 #if defined RTL_STRING_UNITTEST
2405 ::detail::OStringHolder
<L
> operator ""_tstr() {
2407 #if defined RTL_STRING_UNITTEST
2412 ::detail::OStringHolder
<L
>();
2419 Make OString hashable by default for use in STL containers.
2421 @since LibreOffice 6.0
2423 #if defined LIBO_INTERNAL_ONLY
2427 struct hash
<::rtl::OString
>
2429 std::size_t operator()(::rtl::OString
const & s
) const
2431 if constexpr (sizeof(std::size_t) == 8)
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
)
2440 return std::size_t(s
.hashCode());
2449 #endif // INCLUDED_RTL_STRING_HXX
2451 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */