24 #ifndef INCLUDED_RTL_USTRING_HXX 25 #define INCLUDED_RTL_USTRING_HXX 37 #if defined LIBO_INTERNAL_ONLY 39 #include <string_view> 40 #include <type_traits> 49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 50 #include "config_global.h" 51 #include "o3tl/safeint.hxx" 52 #include "rtl/stringconcat.hxx" 55 #ifdef RTL_STRING_UNITTEST 56 extern bool rtl_string_unittest_invalid_conversion;
64 #ifdef RTL_STRING_UNITTEST 65 #define rtl rtlunittest 73 #ifdef RTL_STRING_UNITTEST 77 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 87 static_assert(N != 0);
88 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
91 #if HAVE_CPP_CONSTEVAL 96 OUStringLiteral(char16_t
const (&literal)[N]) {
98 assert(literal[N - 1] ==
'\0');
99 std::copy_n(literal, N, more.buffer);
102 constexpr sal_Int32 getLength()
const {
return more.length; }
104 constexpr
sal_Unicode const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
106 constexpr
operator std::u16string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
109 static constexpr
void assertLayout() {
112 static_assert(std::is_standard_layout_v<OUStringLiteral>);
113 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
114 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
115 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
122 sal_Int32 length = N - 1;
135 #if defined RTL_STRING_UNITTEST 136 namespace libreoffice_internal {
137 template<std::
size_t N>
struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
138 template<std::
size_t N>
struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
192 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 198 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 199 if (std::is_constant_evaluated()) {
211 #if defined LIBO_INTERNAL_ONLY 212 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions 219 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 225 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 226 if (std::is_constant_evaluated()) {
253 #if defined LIBO_INTERNAL_ONLY 282 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT 293 #if defined LIBO_INTERNAL_ONLY 295 template<
typename T>
explicit OUString(
297 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
298 = libreoffice_internal::Dummy()):
302 template<
typename T>
explicit OUString(
305 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
306 = libreoffice_internal::Dummy()):
354 template<
typename T >
369 #ifdef RTL_STRING_UNITTEST 370 rtl_string_unittest_const_literal =
true;
374 #if defined LIBO_INTERNAL_ONLY 386 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST 392 template<
typename T >
393 OUString( T&,
typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
397 rtl_string_unittest_invalid_conversion =
true;
403 template<
typename T >
404 OUString(
const T&,
typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
408 rtl_string_unittest_invalid_conversion =
true;
413 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 420 template<std::
size_t N> constexpr OUString(OUStringLiteral<N>
const & literal):
421 pData(const_cast<rtl_uString *>(&literal.str)) {}
422 template<std::
size_t N> OUString(OUStringLiteral<N> &&) =
delete;
426 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 428 template<OStringLiteral L> OUString(detail::OStringHolder<L>
const & holder) {
430 if (holder.literal.getLength() == 0) {
434 &pData, holder.literal.getStr(), holder.literal.getLength(), 0);
460 throw std::bad_alloc();
481 sal_uInt32
const * codePoints, sal_Int32 codePointCount):
486 throw std::bad_alloc();
490 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 495 template<
typename T1,
typename T2 >
496 OUString( OUStringConcat< T1, T2 >&& c )
498 const sal_Int32 l = c.length();
512 template< std::
size_t N >
513 OUString( OUStringNumber< N >&& n )
514 : OUString( n.buf, n.length )
518 #if defined LIBO_INTERNAL_ONLY 519 explicit OUString(std::u16string_view sv) {
520 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
521 throw std::bad_alloc();
531 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 536 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 537 if (std::is_constant_evaluated()) {
561 {
return *
reinterpret_cast< OUString const *
>( ppHandle ); }
563 #if defined LIBO_INTERNAL_ONLY 590 #if defined LIBO_INTERNAL_ONLY 591 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions 600 std::swap(pData, str.pData);
618 template<
typename T >
635 #if defined LIBO_INTERNAL_ONLY 641 operator =(T &) =
delete;
643 OUString & operator =(OUStringChar c) {
649 template<std::
size_t N> OUString & operator =(OUStringLiteral<N>
const & literal) {
651 pData =
const_cast<rtl_uString *
>(&literal.str);
654 template<std::
size_t N> OUString & operator =(OUStringLiteral<N> &&) =
delete;
656 template <std::
size_t N>
657 OUString & operator =(OUStringNumber<N> && n) {
663 OUString & operator =(std::u16string_view sv) {
673 #if defined LIBO_INTERNAL_ONLY 682 inline OUString & operator+=(
const OUStringBuffer & str ) &;
693 #if defined LIBO_INTERNAL_ONLY 697 return internalAppend(str.pData);
699 #if defined LIBO_INTERNAL_ONLY 700 void operator+=(
OUString const &) && =
delete;
711 operator +=(T & literal)
712 #if defined LIBO_INTERNAL_ONLY 724 #if defined LIBO_INTERNAL_ONLY 727 operator +=(T &) && =
delete;
730 #if defined LIBO_INTERNAL_ONLY 735 operator +=(T & literal) & {
744 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
745 operator +=(T &) && =
delete;
748 template<std::
size_t N> OUString & operator +=(OUStringLiteral<N>
const & literal) & {
752 template<std::
size_t N>
void operator +=(OUStringLiteral<N>
const &) && =
delete;
754 OUString & operator +=(std::u16string_view sv) & {
755 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
756 throw std::bad_alloc();
761 void operator +=(std::u16string_view) && =
delete;
764 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 769 template<
typename T1,
typename T2 >
770 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
771 sal_Int32 l = c.length();
776 sal_Unicode* end = c.addData( pData->buffer + pData->length );
781 template<
typename T1,
typename T2>
void operator +=(
782 OUStringConcat<T1, T2> &&) && =
delete;
788 template< std::
size_t N >
789 OUString& operator+=( OUStringNumber< N >&& n ) & {
790 sal_Int32 l = n.length;
795 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
800 template<std::
size_t N>
void operator +=(
801 OUStringNumber<N> &&) && =
delete;
833 return pData->length == 0;
856 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
857 return getStr()[index];
872 #if defined LIBO_INTERNAL_ONLY 873 sal_Int32 compareTo( std::u16string_view str )
const 876 str.data(), str.length() );
882 str.pData->buffer, str.pData->length );
901 #if defined LIBO_INTERNAL_ONLY 902 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength )
const 905 str.data(), str.length(), maxLength );
911 str.pData->buffer, str.pData->length, maxLength );
927 #if defined LIBO_INTERNAL_ONLY 928 sal_Int32 reverseCompareTo(std::u16string_view sv)
const {
930 pData->buffer, pData->length, sv.data(), sv.size());
936 str.pData->buffer, str.pData->length );
945 template<
typename T >
951 pData->buffer, pData->length,
969 if ( pData->length != str.pData->length )
971 if ( pData == str.pData )
974 str.pData->buffer, str.pData->length ) == 0;
991 #if defined LIBO_INTERNAL_ONLY 992 bool equalsIgnoreAsciiCase(std::u16string_view sv)
const {
993 if ( sal_uInt32(pData->length) != sv.size() )
995 if ( pData->buffer == sv.data() )
999 pData->buffer, pData->length, sv.data(), sv.size())
1005 if ( pData->length != str.pData->length )
1007 if ( pData == str.pData )
1010 str.pData->buffer, str.pData->length ) == 0;
1029 #if defined LIBO_INTERNAL_ONLY 1030 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv)
const {
1032 pData->buffer, pData->length, sv.data(), sv.size());
1038 str.pData->buffer, str.pData->length );
1047 template<
typename T >
1056 pData->buffer, pData->length,
1077 #if defined LIBO_INTERNAL_ONLY 1078 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1081 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1089 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1098 template<
typename T >
1105 pData->buffer+fromIndex, pData->length-fromIndex,
1130 #if defined LIBO_INTERNAL_ONLY 1131 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1134 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1142 str.pData->buffer, str.pData->length,
1143 str.pData->length ) == 0;
1152 template<
typename T >
1157 return matchIgnoreAsciiCaseAsciiL(
1206 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1207 sal_Int32 compareToAscii( const
char * asciiStr, sal_Int32 maxLength )
const 1210 asciiStr, maxLength );
1234 asciiStr, asciiStrLength );
1276 if ( pData->length != asciiStrLength )
1280 pData->buffer, asciiStr, asciiStrLength );
1306 #if defined LIBO_INTERNAL_ONLY 1307 bool equalsIgnoreAsciiCaseAscii( std::string_view asciiStr )
const 1309 return o3tl::make_unsigned(pData->length) == asciiStr.length()
1311 pData->buffer, pData->length, asciiStr.data(), asciiStr.length()) == 0;
1338 #if defined LIBO_INTERNAL_ONLY 1339 sal_Int32 compareToIgnoreAsciiCaseAscii( std::string_view asciiStr )
const 1341 sal_Int32 nMax = std::min<size_t>(asciiStr.length(), std::numeric_limits<sal_Int32>::max());
1343 pData->buffer, pData->length, asciiStr.data(), nMax);
1344 if (result == 0 && o3tl::make_unsigned(pData->length) < asciiStr.length())
1371 if ( pData->length != asciiStrLength )
1397 bool matchAsciiL(
const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 )
const 1400 asciiStr, asciiStrLength ) == 0;
1407 #if SAL_TYPES_SIZEOFLONG == 8 1437 asciiStr, asciiStrLength ) == 0;
1444 #if SAL_TYPES_SIZEOFLONG == 8 1463 #if defined LIBO_INTERNAL_ONLY 1464 bool startsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1465 auto const b = match(sv);
1466 if (b && rest !=
nullptr) {
1467 *rest = copy(sv.size());
1473 bool b = match(str);
1474 if (b && rest != NULL) {
1486 template<
typename T >
1488 T & literal,
OUString * rest = NULL)
const 1494 <= sal_uInt32(pData->length))
1500 if (b && rest != NULL) {
1527 #if defined LIBO_INTERNAL_ONLY 1528 bool startsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1529 auto const b = matchIgnoreAsciiCase(sv);
1530 if (b && rest !=
nullptr) {
1531 *rest = copy(sv.size());
1539 bool b = matchIgnoreAsciiCase(str);
1540 if (b && rest != NULL) {
1552 template<
typename T >
1560 <= sal_uInt32(pData->length))
1568 if (b && rest != NULL) {
1589 #if defined LIBO_INTERNAL_ONLY 1590 bool endsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1591 auto const b = sv.size() <= sal_uInt32(pData->length)
1592 && match(sv, pData->length - sv.size());
1593 if (b && rest !=
nullptr) {
1594 *rest = copy(0, (pData->length - sv.size()));
1601 && match(str, getLength() - str.
getLength());
1602 if (b && rest != NULL) {
1603 *rest = copy(0, getLength() - str.
getLength());
1614 template<
typename T >
1622 <= sal_uInt32(pData->length))
1624 (pData->buffer + pData->length
1629 if (b && rest != NULL) {
1652 return asciiStrLength <= pData->length
1654 pData->buffer + pData->length - asciiStrLength, asciiStr,
1678 #if defined LIBO_INTERNAL_ONLY 1679 bool endsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1680 auto const b = sv.size() <= sal_uInt32(pData->length)
1681 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1682 if (b && rest !=
nullptr) {
1683 *rest = copy(0, pData->length - sv.size());
1691 && matchIgnoreAsciiCase(str, getLength() - str.
getLength());
1692 if (b && rest != NULL) {
1693 *rest = copy(0, getLength() - str.
getLength());
1704 template<
typename T >
1712 <= sal_uInt32(pData->length))
1714 (pData->buffer + pData->length
1721 if (b && rest != NULL) {
1741 char const * asciiStr, sal_Int32 asciiStrLength)
const 1743 return asciiStrLength <= pData->length
1745 pData->buffer + pData->length - asciiStrLength,
1746 asciiStrLength, asciiStr, asciiStrLength)
1751 {
return rStr1.
equals(rStr2); }
1757 {
return rStr1.
compareTo( rStr2 ) < 0; }
1759 {
return rStr1.
compareTo( rStr2 ) > 0; }
1761 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1763 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1765 #if defined LIBO_INTERNAL_ONLY 1773 template<
typename T>
1774 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1780 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1786 template<
typename T>
1787 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1793 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1794 operator !=(OUString
const & s1, T
const & s2) {
return !(s1 == s2); }
1796 template<
typename T>
1797 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1798 operator !=(OUString
const & s1, T & s2) {
return !(s1 == s2); }
1800 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1801 operator !=(T
const & s1, OUString
const & s2) {
return !(s1 == s2); }
1803 template<
typename T>
1804 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1805 operator !=(T & s1, OUString
const & s2) {
return !(s1 == s2); }
1810 {
return rStr1.
compareTo( pStr2 ) == 0; }
1828 template<
typename T >
1844 template<
typename T >
1860 template<
typename T >
1876 template<
typename T >
1886 #if defined LIBO_INTERNAL_ONLY 1892 string.pData->buffer,
string.pData->length,
1899 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1900 operator ==(T & literal, OUString
const &
string) {
1903 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1905 libreoffice_internal::ConstCharArrayDetector<T>::length,
1906 string.pData->buffer,
string.pData->length)
1910 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1911 operator !=(OUString
const &
string, T & literal) {
1914 string.pData->buffer,
string.pData->length,
1915 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1917 libreoffice_internal::ConstCharArrayDetector<T>::length)
1921 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1922 operator !=(T & literal, OUString
const &
string) {
1925 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1927 libreoffice_internal::ConstCharArrayDetector<T>::length,
1928 string.pData->buffer,
string.pData->length)
1961 return (ret < 0 ? ret : ret+fromIndex);
2010 #if defined LIBO_INTERNAL_ONLY 2011 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
2013 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2014 return n < 0 ? n : n + fromIndex;
2020 str.pData->buffer, str.pData->length );
2021 return (ret < 0 ? ret : ret+fromIndex);
2030 template<
typename T >
2036 pData->buffer + fromIndex, pData->length - fromIndex,
2039 return n < 0 ? n : n + fromIndex;
2066 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
const 2069 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2070 return ret < 0 ? ret : ret + fromIndex;
2077 #if SAL_TYPES_SIZEOFLONG == 8 2096 #if defined LIBO_INTERNAL_ONLY 2097 sal_Int32 lastIndexOf(std::u16string_view sv)
const {
2099 pData->buffer, pData->length, sv.data(), sv.size());
2105 str.pData->buffer, str.pData->length );
2126 #if defined LIBO_INTERNAL_ONLY 2127 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex)
const {
2134 str.pData->buffer, str.pData->length );
2143 template<
typename T >
2149 pData->buffer, pData->length,
2176 pData->buffer, pData->length, str, len);
2191 return copy(beginIndex, getLength() - beginIndex);
2208 rtl_uString *pNew = NULL;
2213 #if defined LIBO_INTERNAL_ONLY 2226 assert(beginIndex >= 0);
2227 assert(beginIndex <= getLength());
2228 return subView(beginIndex, getLength() - beginIndex);
2245 assert(beginIndex >= 0);
2247 assert(beginIndex <= getLength());
2248 assert(count <= getLength() - beginIndex);
2249 return std::u16string_view(*this).substr(beginIndex, count);
2253 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 2264 rtl_uString* pNew = NULL;
2270 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 2273 return rStr1.
concat( rStr2 );
2278 #ifndef LIBO_INTERNAL_ONLY 2294 rtl_uString* pNew = NULL;
2300 #ifdef LIBO_INTERNAL_ONLY 2303 rtl_uString* pNew = NULL;
2304 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2324 rtl_uString* pNew = NULL;
2347 #if defined LIBO_INTERNAL_ONLY 2348 [[nodiscard]]
OUString replaceFirst(
2349 std::u16string_view from, std::u16string_view to, sal_Int32 * index =
nullptr)
const 2351 rtl_uString * s =
nullptr;
2354 &s, pData, from.data(), from.size(), to.data(), to.size(),
2355 index ==
nullptr ? &i : index);
2360 OUString const & from,
OUString const & to, sal_Int32 * index = NULL)
const 2362 rtl_uString * s = NULL;
2365 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2388 #if defined LIBO_INTERNAL_ONLY 2389 template<
typename T> [[nodiscard]]
2391 T & from, std::u16string_view to, sal_Int32 * index =
nullptr)
const 2394 rtl_uString * s =
nullptr;
2399 index ==
nullptr ? &i : index);
2403 template<
typename T >
2405 sal_Int32 * index = NULL)
const 2408 rtl_uString * s = NULL;
2414 index == NULL ? &i : index);
2437 #if defined LIBO_INTERNAL_ONLY 2438 template<
typename T> [[nodiscard]]
2440 std::u16string_view from, T & to, sal_Int32 * index =
nullptr)
const 2443 rtl_uString * s =
nullptr;
2446 &s, pData, from.data(), from.size(),
2452 template<
typename T >
2454 sal_Int32 * index = NULL)
const 2457 rtl_uString * s = NULL;
2460 &s, pData, from.pData,
2463 index == NULL ? &i : index);
2486 template<
typename T1,
typename T2 >
2492 rtl_uString * s = NULL;
2500 index == NULL ? &i : index);
2519 #if defined LIBO_INTERNAL_ONLY 2521 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0)
const 2523 rtl_uString * s =
nullptr;
2524 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2525 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2532 rtl_uString * s = NULL;
2551 #if defined LIBO_INTERNAL_ONLY 2552 template<
typename T> [[nodiscard]]
2554 T & from, std::u16string_view to)
const 2557 rtl_uString * s =
nullptr;
2564 template<
typename T >
2568 rtl_uString * s = NULL;
2590 #if defined LIBO_INTERNAL_ONLY 2591 template<
typename T> [[nodiscard]]
2593 std::u16string_view from, T & to)
const 2596 rtl_uString * s =
nullptr;
2598 &s, pData, from.data(), from.size(),
2604 template<
typename T >
2608 rtl_uString * s = NULL;
2610 &s, pData, from.pData,
2630 template<
typename T1,
typename T2 >
2636 rtl_uString * s = NULL;
2658 rtl_uString* pNew = NULL;
2675 rtl_uString* pNew = NULL;
2695 rtl_uString* pNew = NULL;
2726 rtl_uString * pNew = NULL;
2746 return getToken(count, separator, n);
2770 return pData->buffer[0];
2881 rtl_uString * pNew = NULL;
2884 throw std::bad_alloc();
2917 sal_uInt32 *pInfo = NULL )
2919 rtl_uString * pNew = NULL;
2921 convertFlags, pInfo );
2923 throw std::bad_alloc();
2953 sal_uInt32 nFlags)
const 2956 pData->length, nEncoding, nFlags);
3011 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1)
const 3014 pData, indexUtf16, incrementCodePoints);
3026 #if defined LIBO_INTERNAL_ONLY 3027 static OUString fromUtf8(std::string_view rSource)
3077 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3079 static auto number(
int i, sal_Int16 radix = 10 )
3083 static auto number(
long long ll, sal_Int16 radix = 10 )
3087 static auto number(
unsigned long long ll, sal_Int16 radix = 10 )
3091 static auto number(
unsigned int i, sal_Int16 radix = 10 )
3093 return number( static_cast< unsigned long long >( i ), radix );
3095 static auto number(
long i, sal_Int16 radix = 10)
3097 return number( static_cast< long long >( i ), radix );
3099 static auto number(
unsigned long i, sal_Int16 radix = 10 )
3101 return number( static_cast< unsigned long long >( i ), radix );
3123 return number( static_cast< unsigned long long >( i ), radix );
3129 return number( static_cast< long long >( i ), radix );
3135 return number( static_cast< unsigned long long >( i ), radix );
3164 rtl_uString* pNew = NULL;
3170 throw std::bad_alloc();
3186 rtl_uString* pNew = NULL;
3192 throw std::bad_alloc();
3197 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3198 static auto boolean(
bool b)
3261 return number( i, radix );
3276 return number( ll, radix );
3324 rtl_uString* pNew = NULL;
3329 #if defined LIBO_INTERNAL_ONLY 3330 static OUString createFromAscii(std::string_view value) {
3331 rtl_uString * p =
nullptr;
3337 #if defined LIBO_INTERNAL_ONLY 3338 operator std::u16string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
3341 #if defined LIBO_INTERNAL_ONLY 3352 template<
typename T> [[nodiscard]]
static 3353 OUStringConcat<OUStringConcatMarker, T>
3354 Concat(T
const & value) {
return OUStringConcat<OUStringConcatMarker, T>(value); }
3359 template<
typename T, std::
size_t N> [[nodiscard]]
static 3360 OUStringConcat<OUStringConcatMarker, T[N]>
3361 Concat(T (& value)[N]) {
return OUStringConcat<OUStringConcatMarker, T[N]>(value); }
3365 OUString & internalAppend( rtl_uString* pOtherData )
3367 rtl_uString* pNewData = NULL;
3369 if (pNewData == NULL) {
3370 throw std::bad_alloc();
3379 #if defined LIBO_INTERNAL_ONLY 3385 void operator ==(OUString
const &, std::nullptr_t) =
delete;
3386 void operator ==(std::nullptr_t, OUString
const &) =
delete;
3387 void operator !=(OUString
const &, std::nullptr_t) =
delete;
3388 void operator !=(std::nullptr_t, OUString
const &) =
delete;
3391 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 3392 inline bool operator ==(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3393 {
return lhs == std::u16string_view(rhs); }
3394 inline bool operator !=(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3395 {
return lhs != std::u16string_view(rhs); }
3396 inline bool operator ==(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3397 {
return std::u16string_view(lhs) == rhs; }
3398 inline bool operator !=(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3399 {
return std::u16string_view(lhs) != rhs; }
3402 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3409 struct ToStringHelper< OUString >
3411 static std::size_t length(
const OUString& s ) {
return s.getLength(); }
3412 sal_Unicode* operator() (
sal_Unicode* buffer,
const OUString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
3418 template<std::
size_t N>
3419 struct ToStringHelper< OUStringLiteral<N> >
3421 static std::size_t length(
const OUStringLiteral<N>& str ) {
return str.getLength(); }
3422 sal_Unicode* operator()(
sal_Unicode* buffer,
const OUStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3428 template<
typename charT,
typename traits,
typename T1,
typename T2 >
3429 inline std::basic_ostream<charT, traits> &
operator <<(
3430 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3432 return stream << OUString( std::move(concat) );
3455 {
return static_cast<size_t>(rString.
hashCode()); }
3477 #if defined LIBO_INTERNAL_ONLY 3482 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3510 #if defined LIBO_INTERNAL_ONLY 3515 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3536 template<
typename charT,
typename traits >
3538 std::basic_ostream<charT, traits> & stream,
OUString const & rString)
3548 #ifdef RTL_STRING_UNITTEST 3551 typedef rtlunittest::OUString OUString;
3558 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 3559 using ::rtl::OUString;
3560 using ::rtl::OUStringHash;
3563 using ::rtl::OUStringLiteral;
3564 using ::rtl::OUStringChar;
3565 using ::rtl::Concat2View;
3568 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 3571 #if defined RTL_STRING_UNITTEST 3576 #if defined RTL_STRING_UNITTEST 3580 operator ""_ustr() {
return L; }
3590 #if defined LIBO_INTERNAL_ONLY 3598 if constexpr (
sizeof(std::size_t) == 8)
3602 for (sal_Int32 i = 0, len = s.
getLength(); i < len; ++i)
SAL_WARN_UNUSED_RESULT OUString replaceAll(OUString const &from, OUString const &to, sal_Int32 fromIndex=0) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2529
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:664
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2262
OString OUStringToOString(const OUString &rUnicode, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
Convert an OUString to an OString, using a specific text encoding.
Definition: ustring.hxx:3518
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2832
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:946
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2189
OUString()
New string containing no characters.
Definition: ustring.hxx:181
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:821
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
OUString OStringToOUString(const OString &rStr, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
Convert an OString to an OUString, using a specific text encoding.
Definition: ustring.hxx:3485
static OUString 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: ustring.hxx:3146
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, 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...
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: ustring.hxx:2031
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
sal_Int32 indexOf(const OUString &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: ustring.hxx:2017
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2858
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2768
bool matchIgnoreAsciiCase(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1139
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1252
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 void rtl_string2UString(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
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: ustring.hxx:1153
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1487
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: ustring.hxx:1099
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1472
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:560
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
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: ustring.hxx:1048
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *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...
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2271
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1231
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3040
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:3010
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
static OUString 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: ustring.hxx:3121
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
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
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:843
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1829
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1554
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1706
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1274
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
Definition: stringutils.hxx:146
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:492
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:879
#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_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
static OUString intern(const char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS, sal_uInt32 *pInfo=NULL)
Return a canonical representation for a converted string.
Definition: ustring.hxx:2914
sal_Int32 lastIndexOf(const OUString &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: ustring.hxx:2131
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
Definition: stringutils.hxx:200
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceAll(T1 &from, T2 &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2632
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1035
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2724
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2952
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: ustring.hxx:2656
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2783
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2206
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(OUString const &from, T &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2605
sal_uInt16 sal_Unicode
Definition: types.h:123
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
Definition: types.h:38
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3322
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:908
SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: ustring.hxx:2673
__sal_NoAcquire
Definition: types.h:370
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition: math.h:53
sal_Int32 indexOfAsciiL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified ASCII substring...
Definition: ustring.hxx:2065
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3443
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3162
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1178
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2180
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(T &from, OUString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2565
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1301
sal_Int32 indexOf(sal_Unicode 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: ustring.hxx:1958
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:247
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1616
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1397
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
Definition: bootstrap.hxx:33
SAL_WARN_UNUSED_RESULT OUString replace(sal_Unicode oldChar, sal_Unicode newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: ustring.hxx:2322
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1003
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1086
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(OUString const &from, T &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2453
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1861
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2800
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:967
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
bool matchIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1434
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3114
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:692
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:192
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:171
libreoffice_internal::ConstCharArrayDetector< T, OUString &>::Type operator=(T &literal)
Assign a new string from an 8-Bit string literal that is expected to contain only characters in the A...
Definition: ustring.hxx:619
definition of a no acquire enum for ctors
Definition: types.h:374
~OUString()
Release the string data.
Definition: ustring.hxx:534
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3064
OUString(const char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
New string from an 8-Bit character buffer array.
Definition: ustring.hxx:453
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(T &from, OUString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2404
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2102
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1649
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *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...
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:268
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode 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...
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3230
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:317
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode 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_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1973
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:195
Definition: stringutils.hxx:148
sal_Int32 lastIndexOfAsciiL(char const *str, sal_Int32 len) const
Returns the index within this string of the last occurrence of the specified ASCII substring...
Definition: ustring.hxx:2173
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_WARN_UNUSED_RESULT OUString replaceAt(sal_Int32 index, sal_Int32 count, const OUString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: ustring.hxx:2292
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1369
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:831
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode 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...
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:422
SAL_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2693
bool startsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1536
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be used.
Definition: types.h:288
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2815
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:333
SAL_DLLPUBLIC void rtl_uString_newFromCodePoints(rtl_uString **newString, sal_uInt32 const *codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C()
Allocate a new string from an array of Unicode code points.
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:584
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
OUString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set ...
Definition: ustring.hxx:355
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3454
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceFirst(T1 &from, T2 &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2488
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1333
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2144
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode 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_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1688
static OUString 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: ustring.hxx:3139
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1845
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1599
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, 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...
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2845
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:808
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2879
static OUString number(long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3127
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3184
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1877
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:480
SAL_WARN_UNUSED_RESULT OUString replaceFirst(OUString const &from, OUString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2359
static OUString 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: ustring.hxx:3133
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2744
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:933
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:276
sal_Int32 lastIndexOf(sal_Unicode 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: ustring.hxx:1990
bool endsWithIgnoreAsciiCaseAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string, ignoring the case of ASCII letters...
Definition: ustring.hxx:1740
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2757
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1940