4 #ifndef INCLUDED_RTL_USTRING_HXX
5 #define INCLUDED_RTL_USTRING_HXX
17 #if defined LIBO_INTERNAL_ONLY
18 #include <string_view>
19 #include <type_traits>
27 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
28 #include "config_global.h"
29 #include "rtl/stringconcat.hxx"
32 #ifdef RTL_STRING_UNITTEST
33 extern bool rtl_string_unittest_invalid_conversion;
41 #ifdef RTL_STRING_UNITTEST
42 #define rtl rtlunittest
50 #ifdef RTL_STRING_UNITTEST
54 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
64 static_assert(N != 0);
65 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
66 friend class OUString;
67 friend class OUStringConstExpr;
70 #if HAVE_CPP_CONSTEVAL
75 OUStringLiteral(char16_t
const (&literal)[N]) {
77 assert(literal[N - 1] ==
'\0');
79 for (std::size_t i = 0; i != N; ++i) {
80 more.buffer[i] = literal[i];
84 constexpr sal_Int32 getLength()
const {
return more.length; }
86 constexpr
sal_Unicode const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
88 constexpr
operator std::u16string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
91 static constexpr
void assertLayout() {
94 static_assert(std::is_standard_layout_v<OUStringLiteral>);
95 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
96 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
97 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
104 sal_Int32 length = N - 1;
114 #if defined RTL_STRING_UNITTEST
115 namespace libreoffice_internal {
116 template<std::
size_t N>
struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
117 template<std::
size_t N>
struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
130 class OUStringConstExpr
133 template<std::
size_t N> constexpr OUStringConstExpr(OUStringLiteral<N>
const & literal):
134 pData(const_cast<rtl_uString *>(&literal.str)) {}
137 template<std::
size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
146 constexpr std::u16string_view asView()
const {
return std::u16string_view(pData->buffer, pData->length); }
148 inline operator const OUString&()
const;
209 #if defined LIBO_INTERNAL_ONLY
257 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
268 #if defined LIBO_INTERNAL_ONLY
270 template<
typename T>
explicit OUString(
272 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
273 = libreoffice_internal::Dummy()):
277 template<
typename T>
explicit OUString(
280 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
281 = libreoffice_internal::Dummy()):
329 template<
typename T >
344 #ifdef RTL_STRING_UNITTEST
345 rtl_string_unittest_const_literal =
true;
349 #if defined LIBO_INTERNAL_ONLY
351 template<
typename T> OUString(
353 typename libreoffice_internal::ConstCharArrayDetector<
354 T, libreoffice_internal::Dummy>::TypeUtf16
355 = libreoffice_internal::Dummy()):
359 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
360 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
365 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
367 libreoffice_internal::ConstCharArrayDetector<T>::length);
372 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
378 template<
typename T >
379 OUString( T&,
typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
383 rtl_string_unittest_invalid_conversion =
true;
389 template<
typename T >
390 OUString(
const T&,
typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
394 rtl_string_unittest_invalid_conversion =
true;
399 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
406 template<std::
size_t N> constexpr OUString(OUStringLiteral<N>
const & literal):
407 pData(const_cast<rtl_uString *>(&literal.str)) {}
408 template<std::
size_t N> OUString(OUStringLiteral<N> &&) =
delete;
433 throw std::bad_alloc();
454 sal_uInt32
const * codePoints, sal_Int32 codePointCount):
459 throw std::bad_alloc();
463 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
468 template<
typename T1,
typename T2 >
469 OUString( OUStringConcat< T1, T2 >&& c )
471 const sal_Int32 l = c.length();
485 template<
typename T, std::
size_t N >
486 OUString( StringNumberBase< sal_Unicode, T, N >&& n )
487 : OUString( n.buf, n.length )
491 #if defined LIBO_INTERNAL_ONLY
492 explicit OUString(std::u16string_view sv) {
493 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
494 throw std::bad_alloc();
521 {
return *
reinterpret_cast< OUString const *
>( ppHandle ); }
523 #if defined LIBO_INTERNAL_ONLY
550 #if defined LIBO_INTERNAL_ONLY
559 std::swap(pData, str.pData);
576 template<
typename T >
593 #if defined LIBO_INTERNAL_ONLY
598 operator =(T & literal) {
604 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
606 libreoffice_internal::ConstCharArrayDetector<T>::length);
612 template<std::
size_t N> OUString & operator =(OUStringLiteral<N>
const & literal) {
614 pData =
const_cast<rtl_uString *
>(&literal.str);
617 template<std::
size_t N> OUString & operator =(OUStringLiteral<N> &&) =
delete;
619 template <
typename T, std::
size_t N>
620 OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
626 OUString & operator =(std::u16string_view sv) {
636 #if defined LIBO_INTERNAL_ONLY
645 inline OUString & operator+=(
const OUStringBuffer & str ) &;
656 #if defined LIBO_INTERNAL_ONLY
660 return internalAppend(str.
pData);
662 #if defined LIBO_INTERNAL_ONLY
663 void operator+=(
OUString const &) && =
delete;
674 operator +=(T & literal)
675 #if defined LIBO_INTERNAL_ONLY
687 #if defined LIBO_INTERNAL_ONLY
690 operator +=(T &) && =
delete;
693 #if defined LIBO_INTERNAL_ONLY
698 operator +=(T & literal) & {
707 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
708 operator +=(T &) && =
delete;
711 template<std::
size_t N> OUString & operator +=(OUStringLiteral<N>
const & literal) & {
715 template<std::
size_t N>
void operator +=(OUStringLiteral<N>
const &) && =
delete;
717 OUString & operator +=(std::u16string_view sv) & {
718 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
719 throw std::bad_alloc();
724 void operator +=(std::u16string_view) && =
delete;
727 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
732 template<
typename T1,
typename T2 >
733 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
734 sal_Int32 l = c.length();
739 sal_Unicode* end = c.addData( pData->buffer + pData->length );
744 template<
typename T1,
typename T2>
void operator +=(
745 OUStringConcat<T1, T2> &&) && =
delete;
751 template<
typename T, std::
size_t N >
752 OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
753 sal_Int32 l = n.length;
758 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
763 template<
typename T, std::
size_t N>
void operator +=(
764 StringNumberBase<sal_Unicode, T, N> &&) && =
delete;
796 return pData->length == 0;
819 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
820 return getStr()[index];
835 #if defined LIBO_INTERNAL_ONLY
836 sal_Int32 compareTo( std::u16string_view str )
const
839 str.data(), str.length() );
864 #if defined LIBO_INTERNAL_ONLY
865 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength )
const
868 str.data(), str.length(), maxLength );
874 str.
pData->buffer, str.
pData->length, maxLength );
890 #if defined LIBO_INTERNAL_ONLY
891 sal_Int32 reverseCompareTo(std::u16string_view sv)
const {
893 pData->buffer, pData->length, sv.data(), sv.size());
908 template<
typename T >
914 pData->buffer, pData->length,
932 if ( pData->length != str.
pData->length )
934 if ( pData == str.
pData )
954 #if defined LIBO_INTERNAL_ONLY
955 bool equalsIgnoreAsciiCase(std::u16string_view sv)
const {
956 if ( sal_uInt32(pData->length) != sv.size() )
958 if ( pData->buffer == sv.data() )
962 pData->buffer, pData->length, sv.data(), sv.size())
968 if ( pData->length != str.
pData->length )
970 if ( pData == str.
pData )
992 #if defined LIBO_INTERNAL_ONLY
993 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv)
const {
995 pData->buffer, pData->length, sv.data(), sv.size());
1010 template<
typename T >
1019 pData->buffer, pData->length,
1040 #if defined LIBO_INTERNAL_ONLY
1041 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1044 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1061 template<
typename T >
1068 pData->buffer+fromIndex, pData->length-fromIndex,
1093 #if defined LIBO_INTERNAL_ONLY
1094 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1097 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1106 str.
pData->length ) == 0;
1115 template<
typename T >
1120 return matchIgnoreAsciiCaseAsciiL(
1169 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1170 sal_Int32 compareToAscii( const
char * asciiStr, sal_Int32 maxLength )
const
1173 asciiStr, maxLength );
1197 asciiStr, asciiStrLength );
1239 if ( pData->length != asciiStrLength )
1243 pData->buffer, asciiStr, asciiStrLength );
1313 if ( pData->length != asciiStrLength )
1339 bool matchAsciiL(
const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 )
const
1342 asciiStr, asciiStrLength ) == 0;
1349 #if SAL_TYPES_SIZEOFLONG == 8
1379 asciiStr, asciiStrLength ) == 0;
1386 #if SAL_TYPES_SIZEOFLONG == 8
1405 #if defined LIBO_INTERNAL_ONLY
1406 bool startsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1407 auto const b = match(sv);
1408 if (b && rest !=
nullptr) {
1409 *rest = copy(sv.size());
1415 bool b = match(str);
1416 if (b && rest != NULL) {
1428 template<
typename T >
1430 T & literal,
OUString * rest = NULL)
const
1436 <= sal_uInt32(pData->length))
1442 if (b && rest != NULL) {
1469 #if defined LIBO_INTERNAL_ONLY
1470 bool startsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1471 auto const b = matchIgnoreAsciiCase(sv);
1472 if (b && rest !=
nullptr) {
1473 *rest = copy(sv.size());
1481 bool b = matchIgnoreAsciiCase(str);
1482 if (b && rest != NULL) {
1494 template<
typename T >
1502 <= sal_uInt32(pData->length))
1510 if (b && rest != NULL) {
1531 #if defined LIBO_INTERNAL_ONLY
1532 bool endsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1533 auto const b = sv.size() <= sal_uInt32(pData->length)
1534 && match(sv, pData->length - sv.size());
1535 if (b && rest !=
nullptr) {
1536 *rest = copy(0, (pData->length - sv.size()));
1543 && match(str, getLength() - str.
getLength());
1544 if (b && rest != NULL) {
1545 *rest = copy(0, getLength() - str.
getLength());
1556 template<
typename T >
1564 <= sal_uInt32(pData->length))
1566 (pData->buffer + pData->length
1571 if (b && rest != NULL) {
1594 return asciiStrLength <= pData->length
1596 pData->buffer + pData->length - asciiStrLength, asciiStr,
1620 #if defined LIBO_INTERNAL_ONLY
1621 bool endsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1622 auto const b = sv.size() <= sal_uInt32(pData->length)
1623 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1624 if (b && rest !=
nullptr) {
1625 *rest = copy(0, pData->length - sv.size());
1633 && matchIgnoreAsciiCase(str, getLength() - str.
getLength());
1634 if (b && rest != NULL) {
1635 *rest = copy(0, getLength() - str.
getLength());
1646 template<
typename T >
1654 <= sal_uInt32(pData->length))
1656 (pData->buffer + pData->length
1663 if (b && rest != NULL) {
1683 char const * asciiStr, sal_Int32 asciiStrLength)
const
1685 return asciiStrLength <= pData->length
1687 pData->buffer + pData->length - asciiStrLength,
1688 asciiStrLength, asciiStr, asciiStrLength)
1693 {
return rStr1.
equals(rStr2); }
1699 {
return rStr1.
compareTo( rStr2 ) < 0; }
1701 {
return rStr1.
compareTo( rStr2 ) > 0; }
1703 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1705 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1707 #if defined LIBO_INTERNAL_ONLY
1715 template<
typename T>
1716 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1722 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1728 template<
typename T>
1729 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1735 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1736 operator !=(OUString
const & s1, T
const & s2) {
return !(s1 == s2); }
1738 template<
typename T>
1739 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1740 operator !=(OUString
const & s1, T & s2) {
return !(s1 == s2); }
1742 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1743 operator !=(T
const & s1, OUString
const & s2) {
return !(s1 == s2); }
1745 template<
typename T>
1746 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1747 operator !=(T & s1, OUString
const & s2) {
return !(s1 == s2); }
1752 {
return rStr1.
compareTo( pStr2 ) == 0; }
1770 template<
typename T >
1786 template<
typename T >
1802 template<
typename T >
1818 template<
typename T >
1828 #if defined LIBO_INTERNAL_ONLY
1834 string.pData->buffer,
string.pData->length,
1841 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1842 operator ==(T & literal, OUString
const &
string) {
1845 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1847 libreoffice_internal::ConstCharArrayDetector<T>::length,
1848 string.pData->buffer,
string.pData->length)
1852 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1853 operator !=(OUString
const &
string, T & literal) {
1856 string.pData->buffer,
string.pData->length,
1857 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1859 libreoffice_internal::ConstCharArrayDetector<T>::length)
1863 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1864 operator !=(T & literal, OUString
const &
string) {
1867 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1869 libreoffice_internal::ConstCharArrayDetector<T>::length,
1870 string.pData->buffer,
string.pData->length)
1903 return (ret < 0 ? ret : ret+fromIndex);
1952 #if defined LIBO_INTERNAL_ONLY
1953 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1955 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1956 return n < 0 ? n : n + fromIndex;
1963 return (ret < 0 ? ret : ret+fromIndex);
1972 template<
typename T >
1978 pData->buffer + fromIndex, pData->length - fromIndex,
1981 return n < 0 ? n : n + fromIndex;
2008 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
const
2011 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2012 return ret < 0 ? ret : ret + fromIndex;
2019 #if SAL_TYPES_SIZEOFLONG == 8
2038 #if defined LIBO_INTERNAL_ONLY
2039 sal_Int32 lastIndexOf(std::u16string_view sv)
const {
2041 pData->buffer, pData->length, sv.data(), sv.size());
2068 #if defined LIBO_INTERNAL_ONLY
2069 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex)
const {
2085 template<
typename T >
2091 pData->buffer, pData->length,
2118 pData->buffer, pData->length, str, len);
2133 return copy(beginIndex, getLength() - beginIndex);
2150 rtl_uString *pNew = NULL;
2155 #if defined LIBO_INTERNAL_ONLY
2168 assert(beginIndex >= 0);
2169 assert(beginIndex <= getLength());
2170 return subView(beginIndex, getLength() - beginIndex);
2187 assert(beginIndex >= 0);
2189 assert(beginIndex <= getLength());
2190 assert(count <= getLength() - beginIndex);
2191 return std::u16string_view(*this).substr(beginIndex, count);
2195 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2206 rtl_uString* pNew = NULL;
2212 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2215 return rStr1.
concat( rStr2 );
2220 #ifndef LIBO_INTERNAL_ONLY
2236 rtl_uString* pNew = NULL;
2242 #ifdef LIBO_INTERNAL_ONLY
2245 rtl_uString* pNew = NULL;
2246 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2266 rtl_uString* pNew = NULL;
2289 #if defined LIBO_INTERNAL_ONLY
2290 [[nodiscard]]
OUString replaceFirst(
2291 std::u16string_view from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2293 rtl_uString * s =
nullptr;
2296 &s, pData, from.data(), from.size(), to.data(), to.size(),
2297 index ==
nullptr ? &i : index);
2302 OUString const & from,
OUString const & to, sal_Int32 * index = NULL)
const
2304 rtl_uString * s = NULL;
2307 &s, pData, from.
pData, to.
pData, index == NULL ? &i : index);
2330 #if defined LIBO_INTERNAL_ONLY
2331 template<
typename T> [[nodiscard]]
2333 T & from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2336 rtl_uString * s =
nullptr;
2341 index ==
nullptr ? &i : index);
2345 template<
typename T >
2347 sal_Int32 * index = NULL)
const
2350 rtl_uString * s = NULL;
2356 index == NULL ? &i : index);
2379 #if defined LIBO_INTERNAL_ONLY
2380 template<
typename T> [[nodiscard]]
2382 std::u16string_view from, T & to, sal_Int32 * index =
nullptr)
const
2385 rtl_uString * s =
nullptr;
2388 &s, pData, from.data(), from.size(),
2394 template<
typename T >
2396 sal_Int32 * index = NULL)
const
2399 rtl_uString * s = NULL;
2402 &s, pData, from.
pData,
2405 index == NULL ? &i : index);
2428 template<
typename T1,
typename T2 >
2434 rtl_uString * s = NULL;
2442 index == NULL ? &i : index);
2461 #if defined LIBO_INTERNAL_ONLY
2463 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0)
const
2465 rtl_uString * s =
nullptr;
2466 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2467 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2474 rtl_uString * s = NULL;
2493 #if defined LIBO_INTERNAL_ONLY
2494 template<
typename T> [[nodiscard]]
2496 T & from, std::u16string_view to)
const
2499 rtl_uString * s =
nullptr;
2506 template<
typename T >
2510 rtl_uString * s = NULL;
2532 #if defined LIBO_INTERNAL_ONLY
2533 template<
typename T> [[nodiscard]]
2535 std::u16string_view from, T & to)
const
2538 rtl_uString * s =
nullptr;
2540 &s, pData, from.data(), from.size(),
2546 template<
typename T >
2550 rtl_uString * s = NULL;
2552 &s, pData, from.
pData,
2572 template<
typename T1,
typename T2 >
2578 rtl_uString * s = NULL;
2600 rtl_uString* pNew = NULL;
2617 rtl_uString* pNew = NULL;
2637 rtl_uString* pNew = NULL;
2668 rtl_uString * pNew = NULL;
2688 return getToken(count, separator, n);
2712 return pData->buffer[0];
2823 rtl_uString * pNew = NULL;
2826 throw std::bad_alloc();
2859 sal_uInt32 *pInfo = NULL )
2861 rtl_uString * pNew = NULL;
2863 convertFlags, pInfo );
2865 throw std::bad_alloc();
2895 sal_uInt32 nFlags)
const
2898 pData->length, nEncoding, nFlags);
2953 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1)
const
2956 pData, indexUtf16, incrementCodePoints);
2968 #if defined LIBO_INTERNAL_ONLY
2969 static OUString fromUtf8(std::string_view rSource)
3019 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3021 static OUStringNumber< int > number(
int i, sal_Int16 radix = 10 )
3023 return OUStringNumber< int >( i, radix );
3025 static OUStringNumber< long long > number(
long long ll, sal_Int16 radix = 10 )
3027 return OUStringNumber< long long >( ll, radix );
3029 static OUStringNumber< unsigned long long > number(
unsigned long long ll, sal_Int16 radix = 10 )
3031 return OUStringNumber< unsigned long long >( ll, radix );
3033 static OUStringNumber< unsigned long long > number(
unsigned int i, sal_Int16 radix = 10 )
3035 return number( static_cast< unsigned long long >( i ), radix );
3037 static OUStringNumber< long long > number(
long i, sal_Int16 radix = 10)
3039 return number( static_cast< long long >( i ), radix );
3041 static OUStringNumber< unsigned long long > number(
unsigned long i, sal_Int16 radix = 10 )
3043 return number( static_cast< unsigned long long >( i ), radix );
3045 static OUStringNumber< float > number(
float f )
3047 return OUStringNumber< float >( f );
3049 static OUStringNumber< double > number(
double d )
3051 return OUStringNumber< double >( d );
3073 return number( static_cast< unsigned long long >( i ), radix );
3079 return number( static_cast< long long >( i ), radix );
3085 return number( static_cast< unsigned long long >( i ), radix );
3190 return number( i, radix );
3205 return number( ll, radix );
3253 rtl_uString* pNew = NULL;
3258 #if defined LIBO_INTERNAL_ONLY
3259 static OUString createFromAscii(std::string_view value) {
3260 rtl_uString * p =
nullptr;
3266 #if defined LIBO_INTERNAL_ONLY
3267 operator std::u16string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
3270 #if defined LIBO_INTERNAL_ONLY
3281 template<
typename T> [[nodiscard]]
static
3282 OUStringConcat<OUStringConcatMarker, T>
3283 Concat(T
const & value) {
return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3288 template<
typename T, std::
size_t N> [[nodiscard]]
static
3289 OUStringConcat<OUStringConcatMarker, T[N]>
3290 Concat(T (& value)[N]) {
return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3294 OUString & internalAppend( rtl_uString* pOtherData )
3296 rtl_uString* pNewData = NULL;
3298 if (pNewData == NULL) {
3299 throw std::bad_alloc();
3308 #if defined LIBO_INTERNAL_ONLY
3310 inline OUStringConstExpr::operator
const OUString &()
const {
return OUString::unacquired(&pData); }
3313 #if defined LIBO_INTERNAL_ONLY
3319 void operator ==(OUString
const &, std::nullptr_t) =
delete;
3320 void operator ==(std::nullptr_t, OUString
const &) =
delete;
3321 void operator !=(OUString
const &, std::nullptr_t) =
delete;
3322 void operator !=(std::nullptr_t, OUString
const &) =
delete;
3325 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3326 inline bool operator ==(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3327 {
return lhs == std::u16string_view(rhs); }
3328 inline bool operator !=(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3329 {
return lhs != std::u16string_view(rhs); }
3330 inline bool operator ==(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3331 {
return std::u16string_view(lhs) == rhs; }
3332 inline bool operator !=(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3333 {
return std::u16string_view(lhs) != rhs; }
3336 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3343 struct ToStringHelper< OUString >
3345 static std::size_t length(
const OUString& s ) {
return s.getLength(); }
3346 sal_Unicode* operator() (
sal_Unicode* buffer,
const OUString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
3352 template<std::
size_t N>
3353 struct ToStringHelper< OUStringLiteral<N> >
3355 static std::size_t length(
const OUStringLiteral<N>& str ) {
return str.getLength(); }
3356 sal_Unicode* operator()(
sal_Unicode* buffer,
const OUStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3362 template<
typename charT,
typename traits,
typename T1,
typename T2 >
3363 inline std::basic_ostream<charT, traits> &
operator <<(
3364 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3366 return stream << OUString( std::move(concat) );
3390 {
return static_cast<size_t>(rString.
hashCode()); }
3412 #if defined LIBO_INTERNAL_ONLY
3417 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3445 #if defined LIBO_INTERNAL_ONLY
3450 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3471 template<
typename charT,
typename traits >
3473 std::basic_ostream<charT, traits> & stream,
OUString const & rString)
3483 #ifdef RTL_STRING_UNITTEST
3486 typedef rtlunittest::OUString OUString;
3493 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3494 using ::rtl::OUString;
3495 using ::rtl::OUStringHash;
3498 using ::rtl::OUStringLiteral;
3499 using ::rtl::OUStringChar;
3500 using ::rtl::Concat2View;
3509 #if defined LIBO_INTERNAL_ONLY
3517 if constexpr (
sizeof(std::size_t) == 8)
3521 for (sal_Int32 i = 0, len = s.
getLength(); i < len; ++i)
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:1558
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:1496
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:655
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2894
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:1116
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:2430
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:97
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:2264
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2800
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.
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2131
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1049
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 float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
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:544
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...
unsigned char sal_Bool
Definition: types.h:18
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:2615
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 sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2167
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
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 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_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:896
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:308
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2787
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.
pData
New string from a character buffer array.
Definition: string.hxx:289
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:1376
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:17
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:966
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:1959
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
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_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2757
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:1102
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:125
__sal_NoAcquire
Definition: types.h:332
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:2234
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:3071
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:930
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:644
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:243
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:998
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_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:2547
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:899
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:2044
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2821
Definition: stringutils.hxx:194
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 sal_Unicode
Definition: types.h:103
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:73
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1287
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1338
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1237
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:618
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:2598
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.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:196
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.
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:2856
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1591
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...
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:203
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.
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:2086
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:2346
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:83
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:2471
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.
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:1630
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:426
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2742
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_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2710
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_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:2952
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.
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:520
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 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 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 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...
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:454
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:2574
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:806
~OUString()
Release the string data.
Definition: ustring.hxx:504
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:2301
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...
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2699
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
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:2073
pData
Definition: ustring.hxx:334
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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:1915
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.
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:964
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_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_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:871
Definition: stringutils.hxx:142
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:1973
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:55
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_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
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_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1141
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_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2725
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2774
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:292
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:229
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_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
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 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:2007
definition of a no acquire enum for ctors
Definition: types.h:336
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:264
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_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...
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:653
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1215
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:2338
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1025
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:3089
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3160
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:2115
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...
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3378
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:3083
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1803
OUString()
New string containing no characters.
Definition: ustring.hxx:192
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1194
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:771
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:2395
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:842
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:2148
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:784
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...
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:987
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:1339
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(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:251
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:1900
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1882
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 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_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:1932
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1311
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:453
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:3096
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2213
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_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3064
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_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...
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:1062
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 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...
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:941
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:577
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1264
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:1429
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3006
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2686
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3389
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:3453
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:48
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1414
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2982
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:3420
Definition: stringutils.hxx:140
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2204
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:1011
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.
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:3077
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3111
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_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...
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:1682
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2666
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 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.
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:909
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1771
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 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:131
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.
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1006
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.
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3126
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.
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:1648
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_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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:1478
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.
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:2635
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:52
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...
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3251
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1541
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:51
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:2507
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:794
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1819
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 sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1787
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.