24 #ifndef INCLUDED_RTL_USTRING_HXX 25 #define INCLUDED_RTL_USTRING_HXX 37 #if defined LIBO_INTERNAL_ONLY 39 #include <string_view> 40 #include <type_traits> 49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 50 #include "config_global.h" 51 #include "o3tl/safeint.hxx" 52 #include "rtl/stringconcat.hxx" 55 #ifdef RTL_STRING_UNITTEST 56 extern bool rtl_string_unittest_invalid_conversion;
64 #ifdef RTL_STRING_UNITTEST 65 #define rtl rtlunittest 73 #ifdef RTL_STRING_UNITTEST 77 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 87 static_assert(N != 0);
88 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
91 #if HAVE_CPP_CONSTEVAL 96 OUStringLiteral(char16_t
const (&literal)[N]) {
98 assert(literal[N - 1] ==
'\0');
99 std::copy_n(literal, N, more.buffer);
102 constexpr sal_Int32 getLength()
const {
return more.length; }
104 constexpr
sal_Unicode const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
106 constexpr
operator std::u16string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
109 static constexpr
void assertLayout() {
112 static_assert(std::is_standard_layout_v<OUStringLiteral>);
113 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
114 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
115 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
122 sal_Int32 length = N - 1;
135 #if defined RTL_STRING_UNITTEST 136 namespace libreoffice_internal {
137 template<std::
size_t N>
struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
138 template<std::
size_t N>
struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
191 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 197 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 198 if (std::is_constant_evaluated()) {
210 #if defined LIBO_INTERNAL_ONLY 217 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 223 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 224 if (std::is_constant_evaluated()) {
250 #if defined LIBO_INTERNAL_ONLY 279 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT 290 #if defined LIBO_INTERNAL_ONLY 292 template<
typename T>
explicit OUString(
294 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
295 = libreoffice_internal::Dummy()):
299 template<
typename T>
explicit OUString(
302 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
303 = libreoffice_internal::Dummy()):
351 template<
typename T >
366 #ifdef RTL_STRING_UNITTEST 367 rtl_string_unittest_const_literal =
true;
371 #if defined LIBO_INTERNAL_ONLY 383 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST 389 template<
typename T >
390 OUString( T&,
typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
394 rtl_string_unittest_invalid_conversion =
true;
400 template<
typename T >
401 OUString(
const T&,
typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
405 rtl_string_unittest_invalid_conversion =
true;
410 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 417 template<std::
size_t N> constexpr OUString(OUStringLiteral<N>
const & literal):
418 pData(const_cast<rtl_uString *>(&literal.str)) {}
419 template<std::
size_t N> OUString(OUStringLiteral<N> &&) =
delete;
423 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 425 template<OStringLiteral L> OUString(detail::OStringHolder<L>
const & holder) {
427 if (holder.literal.getLength() == 0) {
431 &pData, holder.literal.getStr(), holder.literal.getLength(), 0);
457 throw std::bad_alloc();
478 sal_uInt32
const * codePoints, sal_Int32 codePointCount):
483 throw std::bad_alloc();
487 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 492 template<
typename T1,
typename T2 >
493 OUString( OUStringConcat< T1, T2 >&& c )
495 const sal_Int32 l = c.length();
509 template< std::
size_t N >
510 OUString( OUStringNumber< N >&& n )
511 : OUString( n.buf, n.length )
515 #if defined LIBO_INTERNAL_ONLY 516 explicit OUString(std::u16string_view sv) {
517 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
518 throw std::bad_alloc();
528 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 533 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 534 if (std::is_constant_evaluated()) {
558 {
return *
reinterpret_cast< OUString const *
>( ppHandle ); }
560 #if defined LIBO_INTERNAL_ONLY 587 #if defined LIBO_INTERNAL_ONLY 596 std::swap(pData, str.pData);
613 template<
typename T >
630 #if defined LIBO_INTERNAL_ONLY 636 operator =(T &) =
delete;
638 OUString & operator =(OUStringChar c) {
644 template<std::
size_t N> OUString & operator =(OUStringLiteral<N>
const & literal) {
646 pData =
const_cast<rtl_uString *
>(&literal.str);
649 template<std::
size_t N> OUString & operator =(OUStringLiteral<N> &&) =
delete;
651 template <std::
size_t N>
652 OUString & operator =(OUStringNumber<N> && n) {
658 OUString & operator =(std::u16string_view sv) {
668 #if defined LIBO_INTERNAL_ONLY 677 inline OUString & operator+=(
const OUStringBuffer & str ) &;
688 #if defined LIBO_INTERNAL_ONLY 692 return internalAppend(str.pData);
694 #if defined LIBO_INTERNAL_ONLY 695 void operator+=(
OUString const &) && =
delete;
706 operator +=(T & literal)
707 #if defined LIBO_INTERNAL_ONLY 719 #if defined LIBO_INTERNAL_ONLY 722 operator +=(T &) && =
delete;
725 #if defined LIBO_INTERNAL_ONLY 730 operator +=(T & literal) & {
739 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
740 operator +=(T &) && =
delete;
743 template<std::
size_t N> OUString & operator +=(OUStringLiteral<N>
const & literal) & {
747 template<std::
size_t N>
void operator +=(OUStringLiteral<N>
const &) && =
delete;
749 OUString & operator +=(std::u16string_view sv) & {
750 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
751 throw std::bad_alloc();
756 void operator +=(std::u16string_view) && =
delete;
759 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 764 template<
typename T1,
typename T2 >
765 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
766 sal_Int32 l = c.length();
771 sal_Unicode* end = c.addData( pData->buffer + pData->length );
776 template<
typename T1,
typename T2>
void operator +=(
777 OUStringConcat<T1, T2> &&) && =
delete;
783 template< std::
size_t N >
784 OUString& operator+=( OUStringNumber< N >&& n ) & {
785 sal_Int32 l = n.length;
790 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
795 template<std::
size_t N>
void operator +=(
796 OUStringNumber<N> &&) && =
delete;
828 return pData->length == 0;
851 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
852 return getStr()[index];
867 #if defined LIBO_INTERNAL_ONLY 868 sal_Int32 compareTo( std::u16string_view str )
const 871 str.data(), str.length() );
877 str.pData->buffer, str.pData->length );
896 #if defined LIBO_INTERNAL_ONLY 897 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength )
const 900 str.data(), str.length(), maxLength );
906 str.pData->buffer, str.pData->length, maxLength );
922 #if defined LIBO_INTERNAL_ONLY 923 sal_Int32 reverseCompareTo(std::u16string_view sv)
const {
925 pData->buffer, pData->length, sv.data(), sv.size());
931 str.pData->buffer, str.pData->length );
940 template<
typename T >
946 pData->buffer, pData->length,
964 if ( pData->length != str.pData->length )
966 if ( pData == str.pData )
969 str.pData->buffer, str.pData->length ) == 0;
986 #if defined LIBO_INTERNAL_ONLY 987 bool equalsIgnoreAsciiCase(std::u16string_view sv)
const {
988 if ( sal_uInt32(pData->length) != sv.size() )
990 if ( pData->buffer == sv.data() )
994 pData->buffer, pData->length, sv.data(), sv.size())
1000 if ( pData->length != str.pData->length )
1002 if ( pData == str.pData )
1005 str.pData->buffer, str.pData->length ) == 0;
1024 #if defined LIBO_INTERNAL_ONLY 1025 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv)
const {
1027 pData->buffer, pData->length, sv.data(), sv.size());
1033 str.pData->buffer, str.pData->length );
1042 template<
typename T >
1051 pData->buffer, pData->length,
1072 #if defined LIBO_INTERNAL_ONLY 1073 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1076 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1084 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1093 template<
typename T >
1100 pData->buffer+fromIndex, pData->length-fromIndex,
1125 #if defined LIBO_INTERNAL_ONLY 1126 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1129 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1137 str.pData->buffer, str.pData->length,
1138 str.pData->length ) == 0;
1147 template<
typename T >
1152 return matchIgnoreAsciiCaseAsciiL(
1201 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1202 sal_Int32 compareToAscii( const
char * asciiStr, sal_Int32 maxLength )
const 1205 asciiStr, maxLength );
1229 asciiStr, asciiStrLength );
1271 if ( pData->length != asciiStrLength )
1275 pData->buffer, asciiStr, asciiStrLength );
1301 #if defined LIBO_INTERNAL_ONLY 1302 bool equalsIgnoreAsciiCaseAscii( std::string_view asciiStr )
const 1304 return o3tl::make_unsigned(pData->length) == asciiStr.length()
1306 pData->buffer, pData->length, asciiStr.data(), asciiStr.length()) == 0;
1333 #if defined LIBO_INTERNAL_ONLY 1334 sal_Int32 compareToIgnoreAsciiCaseAscii( std::string_view asciiStr )
const 1336 sal_Int32 nMax = std::min<size_t>(asciiStr.length(), std::numeric_limits<sal_Int32>::max());
1338 pData->buffer, pData->length, asciiStr.data(), nMax);
1339 if (result == 0 && o3tl::make_unsigned(pData->length) < asciiStr.length())
1366 if ( pData->length != asciiStrLength )
1392 bool matchAsciiL(
const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 )
const 1395 asciiStr, asciiStrLength ) == 0;
1402 #if SAL_TYPES_SIZEOFLONG == 8 1432 asciiStr, asciiStrLength ) == 0;
1439 #if SAL_TYPES_SIZEOFLONG == 8 1458 #if defined LIBO_INTERNAL_ONLY 1459 bool startsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1460 auto const b = match(sv);
1461 if (b && rest !=
nullptr) {
1462 *rest = copy(sv.size());
1468 bool b = match(str);
1469 if (b && rest != NULL) {
1481 template<
typename T >
1483 T & literal,
OUString * rest = NULL)
const 1489 <= sal_uInt32(pData->length))
1495 if (b && rest != NULL) {
1522 #if defined LIBO_INTERNAL_ONLY 1523 bool startsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1524 auto const b = matchIgnoreAsciiCase(sv);
1525 if (b && rest !=
nullptr) {
1526 *rest = copy(sv.size());
1534 bool b = matchIgnoreAsciiCase(str);
1535 if (b && rest != NULL) {
1547 template<
typename T >
1555 <= sal_uInt32(pData->length))
1563 if (b && rest != NULL) {
1584 #if defined LIBO_INTERNAL_ONLY 1585 bool endsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1586 auto const b = sv.size() <= sal_uInt32(pData->length)
1587 && match(sv, pData->length - sv.size());
1588 if (b && rest !=
nullptr) {
1589 *rest = copy(0, (pData->length - sv.size()));
1596 && match(str, getLength() - str.
getLength());
1597 if (b && rest != NULL) {
1598 *rest = copy(0, getLength() - str.
getLength());
1609 template<
typename T >
1617 <= sal_uInt32(pData->length))
1619 (pData->buffer + pData->length
1624 if (b && rest != NULL) {
1647 return asciiStrLength <= pData->length
1649 pData->buffer + pData->length - asciiStrLength, asciiStr,
1673 #if defined LIBO_INTERNAL_ONLY 1674 bool endsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1675 auto const b = sv.size() <= sal_uInt32(pData->length)
1676 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1677 if (b && rest !=
nullptr) {
1678 *rest = copy(0, pData->length - sv.size());
1686 && matchIgnoreAsciiCase(str, getLength() - str.
getLength());
1687 if (b && rest != NULL) {
1688 *rest = copy(0, getLength() - str.
getLength());
1699 template<
typename T >
1707 <= sal_uInt32(pData->length))
1709 (pData->buffer + pData->length
1716 if (b && rest != NULL) {
1736 char const * asciiStr, sal_Int32 asciiStrLength)
const 1738 return asciiStrLength <= pData->length
1740 pData->buffer + pData->length - asciiStrLength,
1741 asciiStrLength, asciiStr, asciiStrLength)
1746 {
return rStr1.
equals(rStr2); }
1752 {
return rStr1.
compareTo( rStr2 ) < 0; }
1754 {
return rStr1.
compareTo( rStr2 ) > 0; }
1756 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1758 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1760 #if defined LIBO_INTERNAL_ONLY 1768 template<
typename T>
1769 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1775 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1781 template<
typename T>
1782 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1788 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1789 operator !=(OUString
const & s1, T
const & s2) {
return !(s1 == s2); }
1791 template<
typename T>
1792 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1793 operator !=(OUString
const & s1, T & s2) {
return !(s1 == s2); }
1795 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1796 operator !=(T
const & s1, OUString
const & s2) {
return !(s1 == s2); }
1798 template<
typename T>
1799 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1800 operator !=(T & s1, OUString
const & s2) {
return !(s1 == s2); }
1805 {
return rStr1.
compareTo( pStr2 ) == 0; }
1823 template<
typename T >
1839 template<
typename T >
1855 template<
typename T >
1871 template<
typename T >
1881 #if defined LIBO_INTERNAL_ONLY 1887 string.pData->buffer,
string.pData->length,
1894 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1895 operator ==(T & literal, OUString
const &
string) {
1898 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1900 libreoffice_internal::ConstCharArrayDetector<T>::length,
1901 string.pData->buffer,
string.pData->length)
1905 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1906 operator !=(OUString
const &
string, T & literal) {
1909 string.pData->buffer,
string.pData->length,
1910 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1912 libreoffice_internal::ConstCharArrayDetector<T>::length)
1916 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1917 operator !=(T & literal, OUString
const &
string) {
1920 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1922 libreoffice_internal::ConstCharArrayDetector<T>::length,
1923 string.pData->buffer,
string.pData->length)
1956 return (ret < 0 ? ret : ret+fromIndex);
2005 #if defined LIBO_INTERNAL_ONLY 2006 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
2008 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2009 return n < 0 ? n : n + fromIndex;
2015 str.pData->buffer, str.pData->length );
2016 return (ret < 0 ? ret : ret+fromIndex);
2025 template<
typename T >
2031 pData->buffer + fromIndex, pData->length - fromIndex,
2034 return n < 0 ? n : n + fromIndex;
2061 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
const 2064 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2065 return ret < 0 ? ret : ret + fromIndex;
2072 #if SAL_TYPES_SIZEOFLONG == 8 2091 #if defined LIBO_INTERNAL_ONLY 2092 sal_Int32 lastIndexOf(std::u16string_view sv)
const {
2094 pData->buffer, pData->length, sv.data(), sv.size());
2100 str.pData->buffer, str.pData->length );
2121 #if defined LIBO_INTERNAL_ONLY 2122 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex)
const {
2129 str.pData->buffer, str.pData->length );
2138 template<
typename T >
2144 pData->buffer, pData->length,
2171 pData->buffer, pData->length, str, len);
2186 return copy(beginIndex, getLength() - beginIndex);
2203 rtl_uString *pNew = NULL;
2208 #if defined LIBO_INTERNAL_ONLY 2221 assert(beginIndex >= 0);
2222 assert(beginIndex <= getLength());
2223 return subView(beginIndex, getLength() - beginIndex);
2240 assert(beginIndex >= 0);
2242 assert(beginIndex <= getLength());
2243 assert(count <= getLength() - beginIndex);
2244 return std::u16string_view(*this).substr(beginIndex, count);
2248 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 2259 rtl_uString* pNew = NULL;
2265 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 2268 return rStr1.
concat( rStr2 );
2273 #ifndef LIBO_INTERNAL_ONLY 2289 rtl_uString* pNew = NULL;
2295 #ifdef LIBO_INTERNAL_ONLY 2298 rtl_uString* pNew = NULL;
2299 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2319 rtl_uString* pNew = NULL;
2342 #if defined LIBO_INTERNAL_ONLY 2343 [[nodiscard]]
OUString replaceFirst(
2344 std::u16string_view from, std::u16string_view to, sal_Int32 * index =
nullptr)
const 2346 rtl_uString * s =
nullptr;
2349 &s, pData, from.data(), from.size(), to.data(), to.size(),
2350 index ==
nullptr ? &i : index);
2355 OUString const & from,
OUString const & to, sal_Int32 * index = NULL)
const 2357 rtl_uString * s = NULL;
2360 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2383 #if defined LIBO_INTERNAL_ONLY 2384 template<
typename T> [[nodiscard]]
2386 T & from, std::u16string_view to, sal_Int32 * index =
nullptr)
const 2389 rtl_uString * s =
nullptr;
2394 index ==
nullptr ? &i : index);
2398 template<
typename T >
2400 sal_Int32 * index = NULL)
const 2403 rtl_uString * s = NULL;
2409 index == NULL ? &i : index);
2432 #if defined LIBO_INTERNAL_ONLY 2433 template<
typename T> [[nodiscard]]
2435 std::u16string_view from, T & to, sal_Int32 * index =
nullptr)
const 2438 rtl_uString * s =
nullptr;
2441 &s, pData, from.data(), from.size(),
2447 template<
typename T >
2449 sal_Int32 * index = NULL)
const 2452 rtl_uString * s = NULL;
2455 &s, pData, from.pData,
2458 index == NULL ? &i : index);
2481 template<
typename T1,
typename T2 >
2487 rtl_uString * s = NULL;
2495 index == NULL ? &i : index);
2514 #if defined LIBO_INTERNAL_ONLY 2516 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0)
const 2518 rtl_uString * s =
nullptr;
2519 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2520 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2527 rtl_uString * s = NULL;
2546 #if defined LIBO_INTERNAL_ONLY 2547 template<
typename T> [[nodiscard]]
2549 T & from, std::u16string_view to)
const 2552 rtl_uString * s =
nullptr;
2559 template<
typename T >
2563 rtl_uString * s = NULL;
2585 #if defined LIBO_INTERNAL_ONLY 2586 template<
typename T> [[nodiscard]]
2588 std::u16string_view from, T & to)
const 2591 rtl_uString * s =
nullptr;
2593 &s, pData, from.data(), from.size(),
2599 template<
typename T >
2603 rtl_uString * s = NULL;
2605 &s, pData, from.pData,
2625 template<
typename T1,
typename T2 >
2631 rtl_uString * s = NULL;
2653 rtl_uString* pNew = NULL;
2670 rtl_uString* pNew = NULL;
2690 rtl_uString* pNew = NULL;
2721 rtl_uString * pNew = NULL;
2741 return getToken(count, separator, n);
2765 return pData->buffer[0];
2876 rtl_uString * pNew = NULL;
2879 throw std::bad_alloc();
2912 sal_uInt32 *pInfo = NULL )
2914 rtl_uString * pNew = NULL;
2916 convertFlags, pInfo );
2918 throw std::bad_alloc();
2948 sal_uInt32 nFlags)
const 2951 pData->length, nEncoding, nFlags);
3006 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1)
const 3009 pData, indexUtf16, incrementCodePoints);
3021 #if defined LIBO_INTERNAL_ONLY 3022 static OUString fromUtf8(std::string_view rSource)
3072 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3074 static auto number(
int i, sal_Int16 radix = 10 )
3078 static auto number(
long long ll, sal_Int16 radix = 10 )
3082 static auto number(
unsigned long long ll, sal_Int16 radix = 10 )
3086 static auto number(
unsigned int i, sal_Int16 radix = 10 )
3088 return number( static_cast< unsigned long long >( i ), radix );
3090 static auto number(
long i, sal_Int16 radix = 10)
3092 return number( static_cast< long long >( i ), radix );
3094 static auto number(
unsigned long i, sal_Int16 radix = 10 )
3096 return number( static_cast< unsigned long long >( i ), radix );
3118 return number( static_cast< unsigned long long >( i ), radix );
3124 return number( static_cast< long long >( i ), radix );
3130 return number( static_cast< unsigned long long >( i ), radix );
3159 rtl_uString* pNew = NULL;
3165 throw std::bad_alloc();
3181 rtl_uString* pNew = NULL;
3187 throw std::bad_alloc();
3192 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3193 static auto boolean(
bool b)
3256 return number( i, radix );
3271 return number( ll, radix );
3319 rtl_uString* pNew = NULL;
3324 #if defined LIBO_INTERNAL_ONLY 3325 static OUString createFromAscii(std::string_view value) {
3326 rtl_uString * p =
nullptr;
3332 #if defined LIBO_INTERNAL_ONLY 3333 operator std::u16string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
3336 #if defined LIBO_INTERNAL_ONLY 3347 template<
typename T> [[nodiscard]]
static 3348 OUStringConcat<OUStringConcatMarker, T>
3349 Concat(T
const & value) {
return OUStringConcat<OUStringConcatMarker, T>(value); }
3354 template<
typename T, std::
size_t N> [[nodiscard]]
static 3355 OUStringConcat<OUStringConcatMarker, T[N]>
3356 Concat(T (& value)[N]) {
return OUStringConcat<OUStringConcatMarker, T[N]>(value); }
3360 OUString & internalAppend( rtl_uString* pOtherData )
3362 rtl_uString* pNewData = NULL;
3364 if (pNewData == NULL) {
3365 throw std::bad_alloc();
3374 #if defined LIBO_INTERNAL_ONLY 3380 void operator ==(OUString
const &, std::nullptr_t) =
delete;
3381 void operator ==(std::nullptr_t, OUString
const &) =
delete;
3382 void operator !=(OUString
const &, std::nullptr_t) =
delete;
3383 void operator !=(std::nullptr_t, OUString
const &) =
delete;
3386 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 3387 inline bool operator ==(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3388 {
return lhs == std::u16string_view(rhs); }
3389 inline bool operator !=(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3390 {
return lhs != std::u16string_view(rhs); }
3391 inline bool operator ==(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3392 {
return std::u16string_view(lhs) == rhs; }
3393 inline bool operator !=(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3394 {
return std::u16string_view(lhs) != rhs; }
3397 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 3404 struct ToStringHelper< OUString >
3406 static std::size_t length(
const OUString& s ) {
return s.getLength(); }
3407 sal_Unicode* operator() (
sal_Unicode* buffer,
const OUString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
3413 template<std::
size_t N>
3414 struct ToStringHelper< OUStringLiteral<N> >
3416 static std::size_t length(
const OUStringLiteral<N>& str ) {
return str.getLength(); }
3417 sal_Unicode* operator()(
sal_Unicode* buffer,
const OUStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3423 template<
typename charT,
typename traits,
typename T1,
typename T2 >
3424 inline std::basic_ostream<charT, traits> &
operator <<(
3425 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3427 return stream << OUString( std::move(concat) );
3450 {
return static_cast<size_t>(rString.
hashCode()); }
3472 #if defined LIBO_INTERNAL_ONLY 3477 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3505 #if defined LIBO_INTERNAL_ONLY 3510 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3531 template<
typename charT,
typename traits >
3533 std::basic_ostream<charT, traits> & stream,
OUString const & rString)
3543 #ifdef RTL_STRING_UNITTEST 3546 typedef rtlunittest::OUString OUString;
3553 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 3554 using ::rtl::OUString;
3555 using ::rtl::OUStringHash;
3558 using ::rtl::OUStringLiteral;
3559 using ::rtl::OUStringChar;
3560 using ::rtl::Concat2View;
3563 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED) 3566 #if defined RTL_STRING_UNITTEST 3571 #if defined RTL_STRING_UNITTEST 3575 operator ""_ustr() {
return L; }
3585 #if defined LIBO_INTERNAL_ONLY 3593 if constexpr (
sizeof(std::size_t) == 8)
3597 for (sal_Int32 i = 0, len = s.
getLength(); i < len; ++i)
SAL_WARN_UNUSED_RESULT OUString replaceAll(OUString const &from, OUString const &to, sal_Int32 fromIndex=0) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2524
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:659
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2257
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:3513
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2827
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:941
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2184
OUString()
New string containing no characters.
Definition: ustring.hxx:180
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:816
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
OUString OStringToOUString(const OString &rStr, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
Convert an OString to an OUString, using a specific text encoding.
Definition: ustring.hxx:3480
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:3141
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2026
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:2012
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2853
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2763
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:1134
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1247
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:2355
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:685
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1148
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1482
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1094
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1467
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:557
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1043
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2266
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1226
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3035
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:3005
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
static OUString number(unsigned int i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3116
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:675
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:838
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1824
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1549
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1701
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1269
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
Definition: stringutils.hxx:146
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:474
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:874
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
static OUString intern(const char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS, sal_uInt32 *pInfo=NULL)
Return a canonical representation for a converted string.
Definition: ustring.hxx:2909
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:2126
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
Definition: stringutils.hxx:200
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceAll(T1 &from, T2 &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2627
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1030
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2719
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2947
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: ustring.hxx:2651
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2778
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2201
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(OUString const &from, T &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2600
sal_uInt16 sal_Unicode
Definition: types.h:123
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
Definition: types.h:38
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3317
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:903
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:2668
__sal_NoAcquire
Definition: types.h:352
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition: math.h:53
sal_Int32 indexOfAsciiL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified ASCII substring...
Definition: ustring.hxx:2060
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3438
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3157
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1173
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:2179
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(T &from, OUString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2560
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1296
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:1953
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:244
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1611
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1392
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
Definition: bootstrap.hxx:33
SAL_WARN_UNUSED_RESULT OUString replace(sal_Unicode oldChar, sal_Unicode newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: ustring.hxx:2317
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:998
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1081
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:2448
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1856
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2795
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:962
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
bool matchIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1429
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3109
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:687
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:191
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:170
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:614
definition of a no acquire enum for ctors
Definition: types.h:356
~OUString()
Release the string data.
Definition: ustring.hxx:531
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3059
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:450
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:2399
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2097
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1644
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:265
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3225
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:314
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1968
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:194
Definition: stringutils.hxx:148
sal_Int32 lastIndexOfAsciiL(char const *str, sal_Int32 len) const
Returns the index within this string of the last occurrence of the specified ASCII substring...
Definition: ustring.hxx:2168
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_WARN_UNUSED_RESULT OUString replaceAt(sal_Int32 index, sal_Int32 count, const OUString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: ustring.hxx:2287
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1364
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:826
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_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2688
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:1531
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2810
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:330
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:581
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
OUString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set ...
Definition: ustring.hxx:352
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3449
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:2483
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1328
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2139
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1683
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:3134
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1840
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1594
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2840
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:803
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2874
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:3122
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3179
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1872
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:477
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:2354
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:3128
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2739
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:928
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:273
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:1985
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:1735
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2752
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1935