4 #ifndef INCLUDED_RTL_USTRING_HXX
5 #define INCLUDED_RTL_USTRING_HXX
18 #if defined LIBO_INTERNAL_ONLY
19 #include <string_view>
20 #include <type_traits>
28 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
29 #include "config_global.h"
30 #include "rtl/stringconcat.hxx"
33 #ifdef RTL_STRING_UNITTEST
34 extern bool rtl_string_unittest_invalid_conversion;
42 #ifdef RTL_STRING_UNITTEST
43 #define rtl rtlunittest
51 #ifdef RTL_STRING_UNITTEST
55 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
65 static_assert(N != 0);
66 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
67 friend class OUString;
68 friend class OUStringConstExpr;
71 #if HAVE_CPP_CONSTEVAL
76 OUStringLiteral(char16_t
const (&literal)[N]) {
78 assert(literal[N - 1] ==
'\0');
80 for (std::size_t i = 0; i != N; ++i) {
81 more.buffer[i] = literal[i];
85 constexpr sal_Int32 getLength()
const {
return more.length; }
87 constexpr
sal_Unicode const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
89 constexpr
operator std::u16string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
92 static constexpr
void assertLayout() {
95 static_assert(std::is_standard_layout_v<OUStringLiteral>);
96 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
97 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
98 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
105 sal_Int32 length = N - 1;
115 #if defined RTL_STRING_UNITTEST
116 namespace libreoffice_internal {
117 template<std::
size_t N>
struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
118 template<std::
size_t N>
struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
131 class OUStringConstExpr
134 template<std::
size_t N> constexpr OUStringConstExpr(OUStringLiteral<N>
const & literal):
135 pData(const_cast<rtl_uString *>(&literal.str)) {}
138 template<std::
size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
147 constexpr std::u16string_view asView()
const {
return std::u16string_view(pData->buffer, pData->length); }
149 inline operator const OUString&()
const;
210 #if defined LIBO_INTERNAL_ONLY
258 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
269 #if defined LIBO_INTERNAL_ONLY
271 template<
typename T>
explicit OUString(
273 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
274 = libreoffice_internal::Dummy()):
278 template<
typename T>
explicit OUString(
281 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
282 = libreoffice_internal::Dummy()):
330 template<
typename T >
345 #ifdef RTL_STRING_UNITTEST
346 rtl_string_unittest_const_literal =
true;
350 #if defined LIBO_INTERNAL_ONLY
352 template<
typename T> OUString(
354 typename libreoffice_internal::ConstCharArrayDetector<
355 T, libreoffice_internal::Dummy>::TypeUtf16
356 = libreoffice_internal::Dummy()):
360 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
361 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
366 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
368 libreoffice_internal::ConstCharArrayDetector<T>::length);
373 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
379 template<
typename T >
380 OUString( T&,
typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
384 rtl_string_unittest_invalid_conversion =
true;
390 template<
typename T >
391 OUString(
const T&,
typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
395 rtl_string_unittest_invalid_conversion =
true;
400 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
407 template<std::
size_t N> constexpr OUString(OUStringLiteral<N>
const & literal):
408 pData(const_cast<rtl_uString *>(&literal.str)) {}
409 template<std::
size_t N> OUString(OUStringLiteral<N> &&) =
delete;
434 throw std::bad_alloc();
455 sal_uInt32
const * codePoints, sal_Int32 codePointCount):
460 throw std::bad_alloc();
464 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
469 template<
typename T1,
typename T2 >
470 OUString( OUStringConcat< T1, T2 >&& c )
472 const sal_Int32 l = c.length();
486 template<
typename T, std::
size_t N >
487 OUString( StringNumberBase< sal_Unicode, T, N >&& n )
488 : OUString( n.buf, n.length )
492 #if defined LIBO_INTERNAL_ONLY
493 explicit OUString(std::u16string_view sv) {
494 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
495 throw std::bad_alloc();
522 {
return *
reinterpret_cast< OUString const *
>( ppHandle ); }
524 #if defined LIBO_INTERNAL_ONLY
551 #if defined LIBO_INTERNAL_ONLY
560 std::swap(pData, str.pData);
577 template<
typename T >
594 #if defined LIBO_INTERNAL_ONLY
599 operator =(T & literal) {
605 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
607 libreoffice_internal::ConstCharArrayDetector<T>::length);
613 template<std::
size_t N> OUString & operator =(OUStringLiteral<N>
const & literal) {
615 pData =
const_cast<rtl_uString *
>(&literal.str);
618 template<std::
size_t N> OUString & operator =(OUStringLiteral<N> &&) =
delete;
620 template <
typename T, std::
size_t N>
621 OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
627 OUString & operator =(std::u16string_view sv) {
637 #if defined LIBO_INTERNAL_ONLY
646 inline OUString & operator+=(
const OUStringBuffer & str ) &;
657 #if defined LIBO_INTERNAL_ONLY
661 return internalAppend(str.
pData);
663 #if defined LIBO_INTERNAL_ONLY
664 void operator+=(
OUString const &) && =
delete;
675 operator +=(T & literal)
676 #if defined LIBO_INTERNAL_ONLY
688 #if defined LIBO_INTERNAL_ONLY
691 operator +=(T &) && =
delete;
694 #if defined LIBO_INTERNAL_ONLY
699 operator +=(T & literal) & {
708 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
709 operator +=(T &) && =
delete;
712 template<std::
size_t N> OUString & operator +=(OUStringLiteral<N>
const & literal) & {
716 template<std::
size_t N>
void operator +=(OUStringLiteral<N>
const &) && =
delete;
718 OUString & operator +=(std::u16string_view sv) & {
719 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
720 throw std::bad_alloc();
725 void operator +=(std::u16string_view) && =
delete;
728 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
733 template<
typename T1,
typename T2 >
734 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
735 sal_Int32 l = c.length();
740 sal_Unicode* end = c.addData( pData->buffer + pData->length );
745 template<
typename T1,
typename T2>
void operator +=(
746 OUStringConcat<T1, T2> &&) && =
delete;
752 template<
typename T, std::
size_t N >
753 OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
754 sal_Int32 l = n.length;
759 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
764 template<
typename T, std::
size_t N>
void operator +=(
765 StringNumberBase<sal_Unicode, T, N> &&) && =
delete;
797 return pData->length == 0;
820 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
821 return getStr()[index];
836 #if defined LIBO_INTERNAL_ONLY
837 sal_Int32 compareTo( std::u16string_view str )
const
840 str.data(), str.length() );
865 #if defined LIBO_INTERNAL_ONLY
866 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength )
const
869 str.data(), str.length(), maxLength );
875 str.
pData->buffer, str.
pData->length, maxLength );
891 #if defined LIBO_INTERNAL_ONLY
892 sal_Int32 reverseCompareTo(std::u16string_view sv)
const {
894 pData->buffer, pData->length, sv.data(), sv.size());
909 template<
typename T >
915 pData->buffer, pData->length,
933 if ( pData->length != str.
pData->length )
935 if ( pData == str.
pData )
955 #if defined LIBO_INTERNAL_ONLY
956 bool equalsIgnoreAsciiCase(std::u16string_view sv)
const {
957 if ( sal_uInt32(pData->length) != sv.size() )
959 if ( pData->buffer == sv.data() )
963 pData->buffer, pData->length, sv.data(), sv.size())
969 if ( pData->length != str.
pData->length )
971 if ( pData == str.
pData )
993 #if defined LIBO_INTERNAL_ONLY
994 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv)
const {
996 pData->buffer, pData->length, sv.data(), sv.size());
1011 template<
typename T >
1020 pData->buffer, pData->length,
1041 #if defined LIBO_INTERNAL_ONLY
1042 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1045 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1062 template<
typename T >
1069 pData->buffer+fromIndex, pData->length-fromIndex,
1094 #if defined LIBO_INTERNAL_ONLY
1095 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1098 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1107 str.
pData->length ) == 0;
1116 template<
typename T >
1121 return matchIgnoreAsciiCaseAsciiL(
1170 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1171 sal_Int32 compareToAscii( const
char * asciiStr, sal_Int32 maxLength )
const
1174 asciiStr, maxLength );
1198 asciiStr, asciiStrLength );
1240 if ( pData->length != asciiStrLength )
1244 pData->buffer, asciiStr, asciiStrLength );
1314 if ( pData->length != asciiStrLength )
1340 bool matchAsciiL(
const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 )
const
1343 asciiStr, asciiStrLength ) == 0;
1350 #if SAL_TYPES_SIZEOFLONG == 8
1380 asciiStr, asciiStrLength ) == 0;
1387 #if SAL_TYPES_SIZEOFLONG == 8
1406 #if defined LIBO_INTERNAL_ONLY
1407 bool startsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1408 auto const b = match(sv);
1409 if (b && rest !=
nullptr) {
1410 *rest = copy(sv.size());
1416 bool b = match(str);
1417 if (b && rest != NULL) {
1429 template<
typename T >
1431 T & literal,
OUString * rest = NULL)
const
1437 <= sal_uInt32(pData->length))
1443 if (b && rest != NULL) {
1470 #if defined LIBO_INTERNAL_ONLY
1471 bool startsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1472 auto const b = matchIgnoreAsciiCase(sv);
1473 if (b && rest !=
nullptr) {
1474 *rest = copy(sv.size());
1482 bool b = matchIgnoreAsciiCase(str);
1483 if (b && rest != NULL) {
1495 template<
typename T >
1503 <= sal_uInt32(pData->length))
1511 if (b && rest != NULL) {
1532 #if defined LIBO_INTERNAL_ONLY
1533 bool endsWith(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1534 auto const b = sv.size() <= sal_uInt32(pData->length)
1535 && match(sv, pData->length - sv.size());
1536 if (b && rest !=
nullptr) {
1537 *rest = copy(0, (pData->length - sv.size()));
1544 && match(str, getLength() - str.
getLength());
1545 if (b && rest != NULL) {
1546 *rest = copy(0, getLength() - str.
getLength());
1557 template<
typename T >
1565 <= sal_uInt32(pData->length))
1567 (pData->buffer + pData->length
1572 if (b && rest != NULL) {
1595 return asciiStrLength <= pData->length
1597 pData->buffer + pData->length - asciiStrLength, asciiStr,
1621 #if defined LIBO_INTERNAL_ONLY
1622 bool endsWithIgnoreAsciiCase(std::u16string_view sv,
OUString * rest =
nullptr)
const {
1623 auto const b = sv.size() <= sal_uInt32(pData->length)
1624 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1625 if (b && rest !=
nullptr) {
1626 *rest = copy(0, pData->length - sv.size());
1634 && matchIgnoreAsciiCase(str, getLength() - str.
getLength());
1635 if (b && rest != NULL) {
1636 *rest = copy(0, getLength() - str.
getLength());
1647 template<
typename T >
1655 <= sal_uInt32(pData->length))
1657 (pData->buffer + pData->length
1664 if (b && rest != NULL) {
1684 char const * asciiStr, sal_Int32 asciiStrLength)
const
1686 return asciiStrLength <= pData->length
1688 pData->buffer + pData->length - asciiStrLength,
1689 asciiStrLength, asciiStr, asciiStrLength)
1694 {
return rStr1.
equals(rStr2); }
1700 {
return rStr1.
compareTo( rStr2 ) < 0; }
1702 {
return rStr1.
compareTo( rStr2 ) > 0; }
1704 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1706 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1708 #if defined LIBO_INTERNAL_ONLY
1716 template<
typename T>
1717 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1723 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1729 template<
typename T>
1730 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1736 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1737 operator !=(OUString
const & s1, T
const & s2) {
return !(s1 == s2); }
1739 template<
typename T>
1740 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1741 operator !=(OUString
const & s1, T & s2) {
return !(s1 == s2); }
1743 template<
typename T>
friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1744 operator !=(T
const & s1, OUString
const & s2) {
return !(s1 == s2); }
1746 template<
typename T>
1747 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1748 operator !=(T & s1, OUString
const & s2) {
return !(s1 == s2); }
1753 {
return rStr1.
compareTo( pStr2 ) == 0; }
1771 template<
typename T >
1787 template<
typename T >
1803 template<
typename T >
1819 template<
typename T >
1829 #if defined LIBO_INTERNAL_ONLY
1835 string.pData->buffer,
string.pData->length,
1842 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1843 operator ==(T & literal, OUString
const &
string) {
1846 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1848 libreoffice_internal::ConstCharArrayDetector<T>::length,
1849 string.pData->buffer,
string.pData->length)
1853 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1854 operator !=(OUString
const &
string, T & literal) {
1857 string.pData->buffer,
string.pData->length,
1858 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1860 libreoffice_internal::ConstCharArrayDetector<T>::length)
1864 template<
typename T>
friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1865 operator !=(T & literal, OUString
const &
string) {
1868 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1870 libreoffice_internal::ConstCharArrayDetector<T>::length,
1871 string.pData->buffer,
string.pData->length)
1904 return (ret < 0 ? ret : ret+fromIndex);
1953 #if defined LIBO_INTERNAL_ONLY
1954 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0)
const {
1956 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1957 return n < 0 ? n : n + fromIndex;
1964 return (ret < 0 ? ret : ret+fromIndex);
1973 template<
typename T >
1979 pData->buffer + fromIndex, pData->length - fromIndex,
1982 return n < 0 ? n : n + fromIndex;
2009 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
const
2012 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2013 return ret < 0 ? ret : ret + fromIndex;
2020 #if SAL_TYPES_SIZEOFLONG == 8
2039 #if defined LIBO_INTERNAL_ONLY
2040 sal_Int32 lastIndexOf(std::u16string_view sv)
const {
2042 pData->buffer, pData->length, sv.data(), sv.size());
2069 #if defined LIBO_INTERNAL_ONLY
2070 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex)
const {
2086 template<
typename T >
2092 pData->buffer, pData->length,
2119 pData->buffer, pData->length, str, len);
2134 return copy(beginIndex, getLength() - beginIndex);
2151 rtl_uString *pNew = NULL;
2156 #if defined LIBO_INTERNAL_ONLY
2169 assert(beginIndex >= 0);
2170 assert(beginIndex <= getLength());
2171 return subView(beginIndex, getLength() - beginIndex);
2188 assert(beginIndex >= 0);
2190 assert(beginIndex <= getLength());
2191 assert(count <= getLength() - beginIndex);
2192 return std::u16string_view(*this).substr(beginIndex, count);
2201 SAL_WARN_UNUSED_RESULT std::vector<std::u16string_view> split(
const std::u16string &separator = u
" ")
const
2203 std::vector<std::u16string_view> output;
2204 std::u16string_view stringView(*
this);
2209 index = stringView.find(separator);
2210 if (index != stringView.npos)
2213 output.push_back(stringView.substr(0, index));
2215 if (index != stringView.length() - separator.length())
2217 = stringView.substr(index + separator.length(),
2218 stringView.length() - index - separator.length());
2220 index = stringView.npos;
2223 output.push_back(stringView);
2224 }
while (index != stringView.npos);
2230 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2241 rtl_uString* pNew = NULL;
2247 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2250 return rStr1.
concat( rStr2 );
2255 #ifndef LIBO_INTERNAL_ONLY
2271 rtl_uString* pNew = NULL;
2277 #ifdef LIBO_INTERNAL_ONLY
2280 rtl_uString* pNew = NULL;
2281 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2301 rtl_uString* pNew = NULL;
2324 #if defined LIBO_INTERNAL_ONLY
2325 [[nodiscard]]
OUString replaceFirst(
2326 std::u16string_view from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2328 rtl_uString * s =
nullptr;
2331 &s, pData, from.data(), from.size(), to.data(), to.size(),
2332 index ==
nullptr ? &i : index);
2337 OUString const & from,
OUString const & to, sal_Int32 * index = NULL)
const
2339 rtl_uString * s = NULL;
2342 &s, pData, from.
pData, to.
pData, index == NULL ? &i : index);
2365 #if defined LIBO_INTERNAL_ONLY
2366 template<
typename T> [[nodiscard]]
2368 T & from, std::u16string_view to, sal_Int32 * index =
nullptr)
const
2371 rtl_uString * s =
nullptr;
2376 index ==
nullptr ? &i : index);
2380 template<
typename T >
2382 sal_Int32 * index = NULL)
const
2385 rtl_uString * s = NULL;
2391 index == NULL ? &i : index);
2414 #if defined LIBO_INTERNAL_ONLY
2415 template<
typename T> [[nodiscard]]
2417 std::u16string_view from, T & to, sal_Int32 * index =
nullptr)
const
2420 rtl_uString * s =
nullptr;
2423 &s, pData, from.data(), from.size(),
2429 template<
typename T >
2431 sal_Int32 * index = NULL)
const
2434 rtl_uString * s = NULL;
2437 &s, pData, from.
pData,
2440 index == NULL ? &i : index);
2463 template<
typename T1,
typename T2 >
2469 rtl_uString * s = NULL;
2477 index == NULL ? &i : index);
2496 #if defined LIBO_INTERNAL_ONLY
2498 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0)
const
2500 rtl_uString * s =
nullptr;
2501 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2502 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2509 rtl_uString * s = NULL;
2528 #if defined LIBO_INTERNAL_ONLY
2529 template<
typename T> [[nodiscard]]
2531 T & from, std::u16string_view to)
const
2534 rtl_uString * s =
nullptr;
2541 template<
typename T >
2545 rtl_uString * s = NULL;
2567 #if defined LIBO_INTERNAL_ONLY
2568 template<
typename T> [[nodiscard]]
2570 std::u16string_view from, T & to)
const
2573 rtl_uString * s =
nullptr;
2575 &s, pData, from.data(), from.size(),
2581 template<
typename T >
2585 rtl_uString * s = NULL;
2587 &s, pData, from.
pData,
2607 template<
typename T1,
typename T2 >
2613 rtl_uString * s = NULL;
2635 rtl_uString* pNew = NULL;
2652 rtl_uString* pNew = NULL;
2672 rtl_uString* pNew = NULL;
2703 rtl_uString * pNew = NULL;
2723 return getToken(count, separator, n);
2747 return pData->buffer[0];
2858 rtl_uString * pNew = NULL;
2861 throw std::bad_alloc();
2894 sal_uInt32 *pInfo = NULL )
2896 rtl_uString * pNew = NULL;
2898 convertFlags, pInfo );
2900 throw std::bad_alloc();
2930 sal_uInt32 nFlags)
const
2933 pData->length, nEncoding, nFlags);
2988 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1)
const
2991 pData, indexUtf16, incrementCodePoints);
3003 #if defined LIBO_INTERNAL_ONLY
3004 static OUString fromUtf8(std::string_view rSource)
3054 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3056 static OUStringNumber< int > number(
int i, sal_Int16 radix = 10 )
3058 return OUStringNumber< int >( i, radix );
3060 static OUStringNumber< long long > number(
long long ll, sal_Int16 radix = 10 )
3062 return OUStringNumber< long long >( ll, radix );
3064 static OUStringNumber< unsigned long long > number(
unsigned long long ll, sal_Int16 radix = 10 )
3066 return OUStringNumber< unsigned long long >( ll, radix );
3068 static OUStringNumber< unsigned long long > number(
unsigned int i, sal_Int16 radix = 10 )
3070 return number( static_cast< unsigned long long >( i ), radix );
3072 static OUStringNumber< long long > number(
long i, sal_Int16 radix = 10)
3074 return number( static_cast< long long >( i ), radix );
3076 static OUStringNumber< unsigned long long > number(
unsigned long i, sal_Int16 radix = 10 )
3078 return number( static_cast< unsigned long long >( i ), radix );
3080 static OUStringNumber< float > number(
float f )
3082 return OUStringNumber< float >( f );
3084 static OUStringNumber< double > number(
double d )
3086 return OUStringNumber< double >( d );
3108 return number( static_cast< unsigned long long >( i ), radix );
3114 return number( static_cast< long long >( i ), radix );
3120 return number( static_cast< unsigned long long >( i ), radix );
3225 return number( i, radix );
3240 return number( ll, radix );
3288 rtl_uString* pNew = NULL;
3293 #if defined LIBO_INTERNAL_ONLY
3294 static OUString createFromAscii(std::string_view value) {
3295 rtl_uString * p =
nullptr;
3301 #if defined LIBO_INTERNAL_ONLY
3302 operator std::u16string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
3305 #if defined LIBO_INTERNAL_ONLY
3316 template<
typename T> [[nodiscard]]
static
3317 OUStringConcat<OUStringConcatMarker, T>
3318 Concat(T
const & value) {
return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3323 template<
typename T, std::
size_t N> [[nodiscard]]
static
3324 OUStringConcat<OUStringConcatMarker, T[N]>
3325 Concat(T (& value)[N]) {
return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3329 OUString & internalAppend( rtl_uString* pOtherData )
3331 rtl_uString* pNewData = NULL;
3333 if (pNewData == NULL) {
3334 throw std::bad_alloc();
3343 #if defined LIBO_INTERNAL_ONLY
3345 inline OUStringConstExpr::operator
const OUString &()
const {
return OUString::unacquired(&pData); }
3348 #if defined LIBO_INTERNAL_ONLY
3354 void operator ==(OUString
const &, std::nullptr_t) =
delete;
3355 void operator ==(std::nullptr_t, OUString
const &) =
delete;
3356 void operator !=(OUString
const &, std::nullptr_t) =
delete;
3357 void operator !=(std::nullptr_t, OUString
const &) =
delete;
3360 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3361 inline bool operator ==(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3362 {
return lhs == std::u16string_view(rhs); }
3363 inline bool operator !=(OUString
const & lhs, StringConcatenation<char16_t>
const & rhs)
3364 {
return lhs != std::u16string_view(rhs); }
3365 inline bool operator ==(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3366 {
return std::u16string_view(lhs) == rhs; }
3367 inline bool operator !=(StringConcatenation<char16_t>
const & lhs, OUString
const & rhs)
3368 {
return std::u16string_view(lhs) != rhs; }
3371 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3378 struct ToStringHelper< OUString >
3380 static std::size_t length(
const OUString& s ) {
return s.getLength(); }
3381 sal_Unicode* operator() (
sal_Unicode* buffer,
const OUString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
3387 template<std::
size_t N>
3388 struct ToStringHelper< OUStringLiteral<N> >
3390 static std::size_t length(
const OUStringLiteral<N>& str ) {
return str.getLength(); }
3391 sal_Unicode* operator()(
sal_Unicode* buffer,
const OUStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3397 template<
typename charT,
typename traits,
typename T1,
typename T2 >
3398 inline std::basic_ostream<charT, traits> &
operator <<(
3399 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3401 return stream << OUString( std::move(concat) );
3425 {
return static_cast<size_t>(rString.
hashCode()); }
3447 #if defined LIBO_INTERNAL_ONLY
3452 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3480 #if defined LIBO_INTERNAL_ONLY
3485 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3506 template<
typename charT,
typename traits >
3508 std::basic_ostream<charT, traits> & stream,
OUString const & rString)
3518 #ifdef RTL_STRING_UNITTEST
3521 typedef rtlunittest::OUString OUString;
3528 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3529 using ::rtl::OUString;
3530 using ::rtl::OUStringHash;
3533 using ::rtl::OUStringLiteral;
3534 using ::rtl::OUStringChar;
3535 using ::rtl::Concat2View;
3544 #if defined LIBO_INTERNAL_ONLY
3552 if constexpr (
sizeof(std::size_t) == 8)
3556 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:1559
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:1497
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:656
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2929
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:1117
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:2465
#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:2299
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2835
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:2132
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1050
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:545
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:2650
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:897
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:309
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2822
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:1377
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:967
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:1960
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:183
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:2792
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:1103
#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:2269
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:3106
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:931
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:244
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:999
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:2582
#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:2045
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2856
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:1288
#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:1238
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:2633
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:2891
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1592
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:204
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:2087
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:2381
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:2506
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:1631
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:427
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2777
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:2745
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:2987
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:521
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:2609
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:807
~OUString()
Release the string data.
Definition: ustring.hxx:505
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:2336
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:2734
#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:2074
pData
Definition: ustring.hxx:335
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:1916
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:872
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:1974
#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:1142
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:2760
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2809
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:293
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:230
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:2008
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:1216
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:3124
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3195
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:2116
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:3413
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:3118
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1804
OUString()
New string containing no characters.
Definition: ustring.hxx:193
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1195
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:772
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:2430
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:843
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:2149
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:785
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:1340
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:252
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:1901
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1883
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:1933
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1312
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:454
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:3131
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2248
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:3099
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:1063
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:578
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1265
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:1430
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3041
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2721
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3424
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:3488
#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:1415
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3017
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:3455
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:2239
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:1012
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:3112
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:3146
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:1683
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2701
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:910
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:1772
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:3161
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:1649
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:1479
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:2670
#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:3286
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1542
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:2542
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:795
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1820
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:1788
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.