24#ifndef INCLUDED_RTL_USTRING_HXX
25#define INCLUDED_RTL_USTRING_HXX
37#if defined LIBO_INTERNAL_ONLY
47#ifdef LIBO_INTERNAL_ONLY
48#include "config_global.h"
49#include "rtl/stringconcat.hxx"
52#ifdef RTL_STRING_UNITTEST
53extern bool rtl_string_unittest_invalid_conversion;
61#ifdef RTL_STRING_UNITTEST
62#define rtl rtlunittest
70#ifdef RTL_STRING_UNITTEST
74#if defined LIBO_INTERNAL_ONLY
84 static_assert(N != 0);
85 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
86 friend class OUString;
87 friend class OUStringConstExpr;
95 OUStringLiteral(
char16_t const (&literal)[N]) {
97 assert(literal[N - 1] ==
'\0');
99 for (std::size_t i = 0; i != N; ++i) {
100 more.buffer[i] = literal[i];
104 constexpr sal_Int32 getLength()
const {
return more.length; }
106 constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
108 constexpr operator std::u16string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
111 static constexpr void assertLayout() {
114 static_assert(std::is_standard_layout_v<OUStringLiteral>);
115 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
116 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
117 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
124 sal_Int32 length = N - 1;
134#if defined RTL_STRING_UNITTEST
135namespace libreoffice_internal {
136template<std::
size_t N>
struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
137template<std::
size_t N>
struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
150class OUStringConstExpr
153 template<std::
size_t N>
constexpr OUStringConstExpr(OUStringLiteral<N>
const & literal):
154 pData(const_cast<rtl_uString *>(&literal.str)) {}
157 template<std::
size_t N>
constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
166 constexpr std::u16string_view asView()
const {
return std::u16string_view(pData->buffer, pData->length); }
168 inline operator const OUString&()
const;
229#if defined LIBO_INTERNAL_ONLY
277#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
288#if defined LIBO_INTERNAL_ONLY
290 template<
typename T>
explicit OUString(
292 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
293 = libreoffice_internal::Dummy()):
297 template<
typename T>
explicit OUString(
300 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
301 = libreoffice_internal::Dummy()):
349 template<
typename T >
364#ifdef RTL_STRING_UNITTEST
365 rtl_string_unittest_const_literal =
true;
369#if defined LIBO_INTERNAL_ONLY
385 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
387 libreoffice_internal::ConstCharArrayDetector<T>::length);
392#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
398 template<
typename T >
399 OUString( T&,
typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
403 rtl_string_unittest_invalid_conversion =
true;
409 template<
typename T >
410 OUString(
const T&,
typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
414 rtl_string_unittest_invalid_conversion =
true;
419#ifdef LIBO_INTERNAL_ONLY
426 template<std::
size_t N>
constexpr OUString(OUStringLiteral<N>
const & literal):
427 pData(const_cast<rtl_uString *>(&literal.str)) {}
428 template<std::
size_t N> OUString(OUStringLiteral<N> &&) =
delete;
453 throw std::bad_alloc();
474 sal_uInt32
const * codePoints, sal_Int32 codePointCount):
479 throw std::bad_alloc();
483#ifdef LIBO_INTERNAL_ONLY
488 template< typename T1, typename T2 >
489 OUString( OUStringConcat< T1, T2 >&& c )
491 const sal_Int32 l = c.length();
505 template<
typename T, std::
size_t N >
506 OUString( StringNumberBase< sal_Unicode, T, N >&& n )
507 : OUString( n.buf, n.length )
511#if defined LIBO_INTERNAL_ONLY
512 explicit OUString(std::u16string_view sv) {
513 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
514 throw std::bad_alloc();
541 {
return *
reinterpret_cast< OUString const *
>( ppHandle ); }
543#if defined LIBO_INTERNAL_ONLY
570#if defined LIBO_INTERNAL_ONLY
579 std::swap(pData, str.pData);
596 template<
typename T >
613#if defined LIBO_INTERNAL_ONLY
618 operator =(T & literal) {
624 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
626 libreoffice_internal::ConstCharArrayDetector<T>::length);
632 template<std::
size_t N> OUString & operator =(OUStringLiteral<N>
const & literal) {
634 pData =
const_cast<rtl_uString *
>(&literal.str);
637 template<std::
size_t N> OUString & operator =(OUStringLiteral<N> &&) =
delete;
639 template <
typename T, std::
size_t N>
640 OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
646 OUString & operator =(std::u16string_view sv) {
656#if defined LIBO_INTERNAL_ONLY
665 inline OUString & operator+=(
const OUStringBuffer & str ) &;
676#if defined LIBO_INTERNAL_ONLY
680 return internalAppend(str.pData);
682#if defined LIBO_INTERNAL_ONLY
683 void operator+=(
OUString const &) && =
delete;
694 operator +=(T & literal)
695#if defined LIBO_INTERNAL_ONLY
707#if defined LIBO_INTERNAL_ONLY
710 operator +=(T &) && =
delete;
713#if defined LIBO_INTERNAL_ONLY
718 operator +=(T & literal) & {
727 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
728 operator +=(T &) && =
delete;
731 template<std::
size_t N> OUString & operator +=(OUStringLiteral<N>
const & literal) & {
735 template<std::
size_t N>
void operator +=(OUStringLiteral<N>
const &) && =
delete;
737 OUString & operator +=(std::u16string_view sv) & {
738 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
739 throw std::bad_alloc();
744 void operator +=(std::u16string_view) && =
delete;
747#ifdef LIBO_INTERNAL_ONLY
752 template< typename T1, typename T2 >
753 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
754 sal_Int32 l = c.length();
759 sal_Unicode* end = c.addData( pData->buffer + pData->length );
764 template<
typename T1,
typename T2>
void operator +=(
765 OUStringConcat<T1, T2> &&) && =
delete;
771 template<
typename T, std::
size_t N >
772 OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
773 sal_Int32 l = n.length;
778 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
783 template<
typename T, std::
size_t N>
void operator +=(
784 StringNumberBase<sal_Unicode, T, N> &&) && =
delete;
816 return pData->length == 0;
839 assert(index >= 0 &&
static_cast<sal_uInt32
>(index) <
static_cast<sal_uInt32
>(getLength()));
840 return getStr()[index];
855#if defined LIBO_INTERNAL_ONLY
856 sal_Int32 compareTo( std::u16string_view str )
const
859 str.data(), str.length() );
865 str.pData->buffer, str.pData->length );
884#if defined LIBO_INTERNAL_ONLY
885 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength )
const
888 str.data(), str.length(), maxLength );
894 str.pData->buffer, str.pData->length, maxLength );
910#if defined LIBO_INTERNAL_ONLY
911 sal_Int32 reverseCompareTo(std::u16string_view sv)
const {
913 pData->buffer, pData->length, sv.data(), sv.size());
919 str.pData->buffer, str.pData->length );
928 template<
typename T >
934 pData->buffer, pData->length,
952 if ( pData->length != str.pData->length )
954 if ( pData == str.pData )
957 str.pData->buffer, str.pData->length ) == 0;
974#if defined LIBO_INTERNAL_ONLY
975 bool equalsIgnoreAsciiCase(std::u16string_view sv)
const {
976 if ( sal_uInt32(pData->length) != sv.size() )
978 if ( pData->buffer == sv.data() )
982 pData->buffer, pData->length, sv.data(), sv.size())
988 if ( pData->length != str.pData->length )
990 if ( pData == str.pData )
993 str.pData->buffer, str.pData->length ) == 0;
1012#if defined LIBO_INTERNAL_ONLY
1013 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv)
const {
1015 pData->buffer, pData->length, sv.data(), sv.size());
1021 str.pData->buffer, str.pData->length );
1030 template<
typename T >
1039 pData->buffer, pData->length,
1060#if defined LIBO_INTERNAL_ONLY
1061 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1064 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1072 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1081 template<
typename T >
1088 pData->buffer+fromIndex, pData->length-fromIndex,
1113#if defined LIBO_INTERNAL_ONLY
1114 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1117 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1125 str.pData->buffer, str.pData->length,
1126 str.pData->length ) == 0;
1135 template<
typename T >
1140 return matchIgnoreAsciiCaseAsciiL(
1189 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1190 sal_Int32 compareToAscii( const
char * asciiStr, sal_Int32 maxLength )
const
1193 asciiStr, maxLength );
1217 asciiStr, asciiStrLength );
1259 if ( pData->length != asciiStrLength )
1263 pData->buffer, asciiStr, asciiStrLength );
1333 if ( pData->length != asciiStrLength )
1359 bool matchAsciiL(
const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 )
const
1362 asciiStr, asciiStrLength ) == 0;
1369#if SAL_TYPES_SIZEOFLONG == 8
1399 asciiStr, asciiStrLength ) == 0;
1406#if SAL_TYPES_SIZEOFLONG == 8
1425#if defined LIBO_INTERNAL_ONLY
1426 bool startsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1427 auto const b = match(sv);
1428 if (b && rest !=
nullptr) {
1429 *rest = copy(sv.size());
1435 bool b = match(str);
1436 if (b && rest != NULL) {
1448 template<
typename T >
1450 T & literal,
OUString * rest = NULL)
const
1456 <= sal_uInt32(pData->length))
1462 if (b && rest != NULL) {
1489#if defined LIBO_INTERNAL_ONLY
1490 bool startsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1491 auto const b = matchIgnoreAsciiCase(sv);
1492 if (b && rest !=
nullptr) {
1493 *rest = copy(sv.size());
1501 bool b = matchIgnoreAsciiCase(str);
1502 if (b && rest != NULL) {
1514 template<
typename T >
1522 <= sal_uInt32(pData->length))
1530 if (b && rest != NULL) {
1551#if defined LIBO_INTERNAL_ONLY
1552 bool endsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1553 auto const b = sv.size() <= sal_uInt32(pData->length)
1554 && match(sv, pData->length - sv.size());
1555 if (b && rest !=
nullptr) {
1556 *rest = copy(0, (pData->length - sv.size()));
1563 && match(str, getLength() - str.
getLength());
1564 if (b && rest != NULL) {
1565 *rest = copy(0, getLength() - str.
getLength());
1576 template<
typename T >
1584 <= sal_uInt32(pData->length))
1586 (pData->buffer + pData->length
1591 if (b && rest != NULL) {
1614 return asciiStrLength <= pData->length
1616 pData->buffer + pData->length - asciiStrLength, asciiStr,
1640#if defined LIBO_INTERNAL_ONLY
1641 bool endsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1642 auto const b = sv.size() <= sal_uInt32(pData->length)
1643 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1644 if (b && rest !=
nullptr) {
1645 *rest = copy(0, pData->length - sv.size());
1653 && matchIgnoreAsciiCase(str, getLength() - str.
getLength());
1654 if (b && rest != NULL) {
1655 *rest = copy(0, getLength() - str.
getLength());
1666 template<
typename T >
1674 <= sal_uInt32(pData->length))
1676 (pData->buffer + pData->length
1683 if (b && rest != NULL) {
1703 char const * asciiStr, sal_Int32 asciiStrLength)
const
1705 return asciiStrLength <= pData->length
1707 pData->buffer + pData->length - asciiStrLength,
1708 asciiStrLength, asciiStr, asciiStrLength)
1713 {
return rStr1.
equals(rStr2); }
1716 {
return !(operator == ( rStr1, rStr2 )); }
1719 {
return rStr1.
compareTo( rStr2 ) < 0; }
1721 {
return rStr1.
compareTo( rStr2 ) > 0; }
1723 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1725 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1727#if defined LIBO_INTERNAL_ONLY
1730 operator ==(
OUString const & s1, T
const & s2) {
1735 template<
typename T>
1736 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1737 operator ==(OUString
const & s1, T & s2) {
1742 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1743 operator ==(T
const & s1, OUString
const & s2) {
1748 template<
typename T>
1749 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1750 operator ==(T & s1, OUString
const & s2) {
1755 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1756 operator !=(OUString
const & s1, T
const & s2) {
return !(s1 == s2); }
1758 template<
typename T>
1759 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1760 operator !=(OUString
const & s1, T & s2) {
return !(s1 == s2); }
1762 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1763 operator !=(T
const & s1, OUString
const & s2) {
return !(s1 == s2); }
1765 template<
typename T>
1766 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1767 operator !=(T & s1, OUString
const & s2) {
return !(s1 == s2); }
1772 {
return rStr1.
compareTo( pStr2 ) == 0; }
1777 {
return !(operator == ( rStr1, pStr2 )); }
1779 {
return !(operator == ( pStr1, rStr2 )); }
1790 template<
typename T >
1806 template<
typename T >
1822 template<
typename T >
1838 template<
typename T >
1848#if defined LIBO_INTERNAL_ONLY
1851 operator ==(
OUString const &
string, T & literal) {
1854 string.pData->buffer,
string.pData->length,
1861 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1862 operator ==(T & literal, OUString
const &
string) {
1865 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1867 libreoffice_internal::ConstCharArrayDetector<T>::length,
1868 string.pData->buffer,
string.pData->length)
1872 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1873 operator !=(OUString
const &
string, T & literal) {
1876 string.pData->buffer,
string.pData->length,
1877 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1879 libreoffice_internal::ConstCharArrayDetector<T>::length)
1883 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1884 operator !=(T & literal, OUString
const &
string) {
1887 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1889 libreoffice_internal::ConstCharArrayDetector<T>::length,
1890 string.pData->buffer,
string.pData->length)
1923 return (ret < 0 ? ret : ret+fromIndex);
1972#if defined LIBO_INTERNAL_ONLY
1973 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1975 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1976 return n < 0 ? n : n + fromIndex;
1982 str.pData->buffer, str.pData->length );
1983 return (ret < 0 ? ret : ret+fromIndex);
1992 template<
typename T >
1998 pData->buffer + fromIndex, pData->length - fromIndex,
2001 return n < 0 ? n : n + fromIndex;
2028 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
const
2031 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2032 return ret < 0 ? ret : ret + fromIndex;
2039#if SAL_TYPES_SIZEOFLONG == 8
2058#if defined LIBO_INTERNAL_ONLY
2059 sal_Int32 lastIndexOf(std::u16string_view sv)
const {
2061 pData->buffer, pData->length, sv.data(), sv.size());
2067 str.pData->buffer, str.pData->length );
2088#if defined LIBO_INTERNAL_ONLY
2089 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex)
const {
2096 str.pData->buffer, str.pData->length );
2105 template<
typename T >
2111 pData->buffer, pData->length,
2138 pData->buffer, pData->length, str, len);
2153 return copy(beginIndex, getLength() - beginIndex);
2170 rtl_uString *pNew = NULL;
2175#if defined LIBO_INTERNAL_ONLY
2188 assert(beginIndex >= 0);
2189 assert(beginIndex <= getLength());
2190 return subView(beginIndex, getLength() - beginIndex);
2207 assert(beginIndex >= 0);
2209 assert(beginIndex <= getLength());
2210 assert(count <= getLength() - beginIndex);
2211 return std::u16string_view(*this).substr(beginIndex, count);
2215#ifndef LIBO_INTERNAL_ONLY
2224 SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2226 rtl_uString* pNew = NULL;
2232#ifndef LIBO_INTERNAL_ONLY
2235 return rStr1.
concat( rStr2 );
2240#ifndef LIBO_INTERNAL_ONLY
2256 rtl_uString* pNew = NULL;
2262#ifdef LIBO_INTERNAL_ONLY
2265 rtl_uString* pNew = NULL;
2266 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2286 rtl_uString* pNew = NULL;
2309#if defined LIBO_INTERNAL_ONLY
2310 [[nodiscard]]
OUString replaceFirst(
2311 std::u16string_view from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2313 rtl_uString * s =
nullptr;
2316 &s, pData, from.data(), from.size(), to.data(), to.size(),
2317 index ==
nullptr ? &i : index);
2322 OUString const & from,
OUString const & to, sal_Int32 * index = NULL)
const
2324 rtl_uString * s = NULL;
2327 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2350#if defined LIBO_INTERNAL_ONLY
2351 template<
typename T> [[nodiscard]]
2353 T & from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2356 rtl_uString * s =
nullptr;
2361 index ==
nullptr ? &i : index);
2365 template<
typename T >
2367 sal_Int32 * index = NULL)
const
2370 rtl_uString * s = NULL;
2376 index == NULL ? &i : index);
2399#if defined LIBO_INTERNAL_ONLY
2400 template<
typename T> [[nodiscard]]
2402 std::u16string_view from, T & to, sal_Int32 * index =
nullptr)
const
2405 rtl_uString * s =
nullptr;
2408 &s, pData, from.data(), from.size(),
2414 template<
typename T >
2416 sal_Int32 * index = NULL)
const
2419 rtl_uString * s = NULL;
2422 &s, pData, from.pData,
2425 index == NULL ? &i : index);
2448 template<
typename T1,
typename T2 >
2454 rtl_uString * s = NULL;
2462 index == NULL ? &i : index);
2481#if defined LIBO_INTERNAL_ONLY
2483 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0)
const
2485 rtl_uString * s =
nullptr;
2486 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2487 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2494 rtl_uString * s = NULL;
2513#if defined LIBO_INTERNAL_ONLY
2514 template<
typename T> [[nodiscard]]
2516 T & from, std::u16string_view to)
const
2519 rtl_uString * s =
nullptr;
2526 template<
typename T >
2530 rtl_uString * s = NULL;
2552#if defined LIBO_INTERNAL_ONLY
2553 template<
typename T> [[nodiscard]]
2555 std::u16string_view from, T & to)
const
2558 rtl_uString * s =
nullptr;
2560 &s, pData, from.data(), from.size(),
2566 template<
typename T >
2570 rtl_uString * s = NULL;
2572 &s, pData, from.pData,
2592 template<
typename T1,
typename T2 >
2598 rtl_uString * s = NULL;
2620 rtl_uString* pNew = NULL;
2637 rtl_uString* pNew = NULL;
2657 rtl_uString* pNew = NULL;
2688 rtl_uString * pNew = NULL;
2708 return getToken(count, separator, n);
2732 return pData->buffer[0];
2843 rtl_uString * pNew = NULL;
2846 throw std::bad_alloc();
2879 sal_uInt32 *pInfo = NULL )
2881 rtl_uString * pNew = NULL;
2883 convertFlags, pInfo );
2885 throw std::bad_alloc();
2915 sal_uInt32 nFlags)
const
2918 pData->length, nEncoding, nFlags);
2973 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1)
const
2976 pData, indexUtf16, incrementCodePoints);
2988#if defined LIBO_INTERNAL_ONLY
2989 static OUString fromUtf8(std::string_view rSource)
3039#ifdef LIBO_INTERNAL_ONLY
3041 static OUStringNumber< int > number(
int i, sal_Int16 radix = 10 )
3043 return OUStringNumber< int >( i, radix );
3045 static OUStringNumber< long long > number(
long long ll, sal_Int16 radix = 10 )
3047 return OUStringNumber< long long >( ll, radix );
3049 static OUStringNumber< unsigned long long > number(
unsigned long long ll, sal_Int16 radix = 10 )
3051 return OUStringNumber< unsigned long long >( ll, radix );
3053 static OUStringNumber< unsigned long long > number(
unsigned int i, sal_Int16 radix = 10 )
3055 return number(
static_cast< unsigned long long >( i ), radix );
3057 static OUStringNumber< long long > number(
long i, sal_Int16 radix = 10)
3059 return number(
static_cast< long long >( i ), radix );
3061 static OUStringNumber< unsigned long long > number(
unsigned long i, sal_Int16 radix = 10 )
3063 return number(
static_cast< unsigned long long >( i ), radix );
3065 static OUStringNumber< float > number(
float f )
3067 return OUStringNumber< float >( f );
3069 static OUStringNumber< double > number(
double d )
3071 return OUStringNumber< double >( d );
3093 return number(
static_cast< unsigned long long >( i ), radix );
3099 return number(
static_cast< long long >( i ), radix );
3105 return number(
static_cast< unsigned long long >( i ), radix );
3210 return number( i, radix );
3225 return number( ll, radix );
3273 rtl_uString* pNew = NULL;
3278#if defined LIBO_INTERNAL_ONLY
3279 static OUString createFromAscii(std::string_view value) {
3280 rtl_uString * p =
nullptr;
3286#if defined LIBO_INTERNAL_ONLY
3287 operator std::u16string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
3290#if defined LIBO_INTERNAL_ONLY
3301 template<
typename T> [[nodiscard]]
static
3302 OUStringConcat<OUStringConcatMarker, T>
3303 Concat(T
const & value) {
return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3308 template<
typename T, std::
size_t N> [[nodiscard]]
static
3309 OUStringConcat<OUStringConcatMarker, T[N]>
3310 Concat(T (& value)[N]) {
return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3314 OUString & internalAppend( rtl_uString* pOtherData )
3316 rtl_uString* pNewData = NULL;
3318 if (pNewData == NULL) {
3319 throw std::bad_alloc();
3328#if defined LIBO_INTERNAL_ONLY
3330inline OUStringConstExpr::operator
const OUString &()
const {
return OUString::unacquired(&pData); }
3333#if defined LIBO_INTERNAL_ONLY
3339void operator ==(OUString
const &, std::nullptr_t) =
delete;
3340void operator ==(std::nullptr_t, OUString
const &) =
delete;
3341void operator !=(OUString
const &, std::nullptr_t) =
delete;
3342void operator !=(std::nullptr_t, OUString
const &) =
delete;
3345#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3346inline bool operator ==(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3347{
return lhs == std::u16string_view(rhs); }
3348inline bool operator !=(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3349{
return lhs != std::u16string_view(rhs); }
3350inline bool operator ==(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3351{
return std::u16string_view(lhs) == rhs; }
3352inline bool operator !=(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3353{
return std::u16string_view(lhs) != rhs; }
3356#if defined LIBO_INTERNAL_ONLY
3363struct ToStringHelper< OUString >
3365 static std::size_t length(
const OUString& s ) {
return s.getLength(); }
3366 sal_Unicode* operator() (
sal_Unicode* buffer,
const OUString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
3372template<std::
size_t N>
3373struct ToStringHelper< OUStringLiteral<N> >
3375 static std::size_t length(
const OUStringLiteral<N>& str ) {
return str.getLength(); }
3376 sal_Unicode* operator()(
sal_Unicode* buffer,
const OUStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3382template<
typename charT,
typename traits,
typename T1,
typename T2 >
3383inline std::basic_ostream<charT, traits> &
operator <<(
3384 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3386 return stream << OUString( std::move(concat) );
3409 {
return static_cast<size_t>(rString.
hashCode()); }
3431#if defined LIBO_INTERNAL_ONLY
3436 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3464#if defined LIBO_INTERNAL_ONLY
3469 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3490template<
typename charT,
typename traits >
3491inline std::basic_ostream<charT, traits> &
operator <<(
3492 std::basic_ostream<charT, traits> & stream, OUString
const & rString)
3502#ifdef RTL_STRING_UNITTEST
3505typedef rtlunittest::OUString OUString;
3512#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3513using ::rtl::OUString;
3514using ::rtl::OUStringHash;
3515using ::rtl::OStringToOUString;
3516using ::rtl::OUStringToOString;
3517using ::rtl::OUStringLiteral;
3518using ::rtl::OUStringChar;
3519using ::rtl::Concat2View;
3528#if defined LIBO_INTERNAL_ONLY
3536 if constexpr (
sizeof(std::size_t) == 8)
3540 for (sal_Int32 i = 0, len = s.
getLength(); i < len; ++i)
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition types.h:474
__sal_NoAcquire
Definition types.h:353
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition types.h:356
unsigned char sal_Bool
Definition types.h:38
sal_uInt16 sal_Unicode
Definition types.h:123
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition types.h:284
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:587
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.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition string.h:1358
#define RTL_TEXTENCODING_UTF8
Definition textenc.h:117
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition textenc.h:37
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 void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
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 float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
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.
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:2187
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition ustring.h:1026
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.
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.
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_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 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_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.
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition ustring.h:1045
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_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 void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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 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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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.
#define RTL_USTR_MAX_VALUEOFINT64
Definition ustring.h:984
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.
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.
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_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
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.
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.
#define RTL_USTR_MAX_VALUEOFUINT64
Definition ustring.h:1007
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.
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.
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.
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 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 void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
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_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_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 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_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.
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.
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.
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.
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.
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.
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.
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.
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_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
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 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_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_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition ustring.h:919
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
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.
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.
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.
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_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
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.
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.
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_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.
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.
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_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.
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.
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.
#define RTL_USTR_MAX_VALUEOFINT32
Definition ustring.h:961
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition textcvt.h:151
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition textcvt.h:75
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition textcvt.h:72
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition textcvt.h:68
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition textcvt.h:145
sal_Int32 oslInterlockedCount
Definition interlck.h:44
Definition bootstrap.hxx:34
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,...
Definition string.hxx:2325
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:3439
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:3472
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition string.hxx:216
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition string.hxx:663
sal_Int32 getLength() const
Returns the length of this string.
Definition string.hxx:637
Definition stringutils.hxx:140
Definition stringutils.hxx:143
Definition stringutils.hxx:195
A string buffer implements a mutable sequence of characters.
Definition ustrbuf.hxx:72
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:203
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition ustring.hxx:3084
OUString intern() const
Return a canonical representation for a string.
Definition ustring.hxx:2841
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustring.hxx:1993
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition ustring.hxx:1561
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:1702
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:2618
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:2527
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition ustring.hxx:826
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition ustring.hxx:986
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition ustring.hxx:1611
OUString(const OUString &str)
New string from OUString.
Definition ustring.hxx:223
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:2972
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition ustring.hxx:3002
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustring.hxx:1082
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition ustring.hxx:2745
void clear()
Clears the string, i.e, makes a zero-character string.
Definition ustring.hxx:791
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition ustring.hxx:1331
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:3116
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:2027
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typenamelibreoffice_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:2594
~OUString()
Release the string data.
Definition ustring.hxx:524
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition ustring.hxx:891
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:2135
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,...
Definition ustring.hxx:1920
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:2567
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:3109
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition ustring.hxx:1359
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:2491
float toFloat() const
Returns the float value from this string.
Definition ustring.hxx:2807
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:3103
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition ustring.hxx:3271
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:2366
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typenamelibreoffice_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:2450
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:2284
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition ustring.hxx:1902
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 o...
Definition ustring.hxx:929
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition ustring.hxx:1807
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition ustring.hxx:1791
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:3097
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustring.hxx:1031
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition ustring.hxx:2794
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:1396
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 o...
Definition ustring.hxx:1516
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition ustring.hxx:3026
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition ustring.hxx:1214
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition ustring.hxx:1257
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:3091
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition ustring.hxx:2914
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 o...
Definition ustring.hxx:1449
OUString(rtl_uString *str)
New string from OUString data.
Definition ustring.hxx:249
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition ustring.hxx:328
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:1650
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition ustring.hxx:862
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition ustring.hxx:1823
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:597
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition ustring.hxx:1434
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition ustring.hxx:1935
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition ustring.hxx:1307
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:2415
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition ustring.hxx:271
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:2321
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition ustring.hxx:2777
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition ustring.hxx:2762
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:1498
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition ustring.hxx:2093
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition ustring.hxx:540
double toDouble() const
Returns the double value from this string.
Definition ustring.hxx:2820
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition ustring.hxx:1235
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustring.hxx:1136
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition ustring.hxx:2686
sal_Int32 getLength() const
Returns the length of this string.
Definition ustring.hxx:804
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition ustring.hxx:1284
OUString()
New string containing no characters.
Definition ustring.hxx:212
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition ustring.hxx:312
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:446
OUString & operator=(const OUString &str)
Assign a new string.
Definition ustring.hxx:564
static OUString number(float f)
Returns the string representation of the float argument.
Definition ustring.hxx:3131
bool isEmpty() const
Checks if a string is empty.
Definition ustring.hxx:814
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition ustring.hxx:1018
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition ustring.hxx:473
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 o...
Definition ustring.hxx:1578
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition ustring.hxx:675
sal_Unicode toChar() const
Returns the first character from this string.
Definition ustring.hxx:2730
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition ustring.hxx:2706
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition ustring.hxx:3180
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 o...
Definition ustring.hxx:2106
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:2168
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 o...
Definition ustring.hxx:1668
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition ustring.hxx:263
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition ustring.hxx:1952
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:2655
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:2635
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition ustring.hxx:2224
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:2254
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition ustring.hxx:1069
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:1122
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition ustring.hxx:1161
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:350
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition ustring.hxx:916
static OUString number(double d)
Returns the string representation of the double argument.
Definition ustring.hxx:3146
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition ustring.hxx:2233
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition ustring.hxx:2151
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition ustring.hxx:1839
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition ustring.hxx:950
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition ustring.hxx:2064
bool toBoolean() const
Returns the Boolean value from this string.
Definition ustring.hxx:2719
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,...
Definition ustring.hxx:1979
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:2876
A helper to use OUStrings with hash maps.
Definition ustring.hxx:3398
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition ustring.hxx:3408