4 #ifndef INCLUDED_RTL_STRING_HXX
5 #define INCLUDED_RTL_STRING_HXX
19 #if defined LIBO_INTERNAL_ONLY
20 #include <string_view>
21 #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_const_literal;
35 extern bool rtl_string_unittest_const_literal_function;
43 #ifdef RTL_STRING_UNITTEST
44 #define rtl rtlunittest
51 #ifdef RTL_STRING_UNITTEST
54 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
56 #define RTL_STRING_CONST_FUNCTION
60 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
69 static_assert(N != 0);
70 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
72 friend class OStringConstExpr;
75 #if HAVE_CPP_CONSTEVAL
80 OStringLiteral(
char const (&literal)[N]) {
82 assert(literal[N - 1] ==
'\0');
84 for (std::size_t i = 0; i != N; ++i) {
85 more.buffer[i] = literal[i];
89 #if defined __cpp_char8_t
90 #if HAVE_CPP_CONSTEVAL
95 explicit OStringLiteral(char8_t
const (&literal)[N]) {
97 assert(literal[N - 1] ==
'\0');
99 for (std::size_t i = 0; i != N; ++i) {
100 more.buffer[i] = literal[i];
105 constexpr sal_Int32 getLength()
const {
return more.length; }
107 constexpr
char const * getStr() const SAL_RETURNS_NONNULL {
return more.buffer; }
109 constexpr
operator std::string_view()
const {
return {more.buffer, sal_uInt32(more.length)}; }
112 static constexpr
void assertLayout() {
115 static_assert(std::is_standard_layout_v<OStringLiteral>);
116 static_assert(offsetof(OStringLiteral, str.refCount) == offsetof(OStringLiteral, more.refCount));
117 static_assert(offsetof(OStringLiteral, str.length) == offsetof(OStringLiteral, more.length));
118 static_assert(offsetof(OStringLiteral, str.buffer) == offsetof(OStringLiteral, more.buffer));
125 sal_Int32 length = N - 1;
144 class OStringConstExpr
147 template<std::
size_t N> constexpr OStringConstExpr(OStringLiteral<N>
const & literal):
148 pData(const_cast<rtl_String *>(&literal.str)) {}
151 template<std::
size_t N> constexpr OStringConstExpr(OStringLiteral<N> && literal)
160 constexpr std::string_view asView()
const {
return std::string_view(pData->buffer, pData->length); }
162 inline operator const OString&()
const;
223 #if defined LIBO_INTERNAL_ONLY
272 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
286 template<
typename T >
293 template<
typename T >
300 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
301 template<
typename T >
302 OString( T&& value,
typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
319 template<
typename T >
320 OString( T& literal,
typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
323 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
334 #ifdef RTL_STRING_UNITTEST
335 rtl_string_unittest_const_literal =
true;
347 OString(
const char * value, sal_Int32 length )
353 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
360 template<std::
size_t N> constexpr
OString(OStringLiteral<N>
const & literal):
361 pData(const_cast<rtl_String *>(&literal.str)) {}
362 template<std::
size_t N> OString(OStringLiteral<N> &&) =
delete;
366 #if defined LIBO_INTERNAL_ONLY
367 explicit OString(std::string_view sv) {
368 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
369 throw std::bad_alloc();
397 throw std::bad_alloc();
401 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
406 template<
typename T1,
typename T2 >
407 OString( OStringConcat< T1, T2 >&& c )
409 const sal_Int32 l = c.length();
413 char* end = c.addData( pData->buffer );
423 template<
typename T, std::
size_t N >
424 OString( StringNumberBase< char, T, N >&& n )
425 : OString( n.buf, n.length )
429 #ifdef LIBO_INTERNAL_ONLY
430 OString(std::nullptr_t) =
delete;
441 #if defined LIBO_INTERNAL_ONLY
453 static OString const & unacquired( rtl_String *
const * ppHandle )
454 {
return *
reinterpret_cast< OString const *
>( ppHandle ); }
468 #if defined LIBO_INTERNAL_ONLY
490 template<
typename T >
493 RTL_STRING_CONST_FUNCTION
514 #if defined LIBO_INTERNAL_ONLY
521 #if defined LIBO_INTERNAL_ONLY
522 void operator+=(
OString const &) && =
delete;
525 #if defined LIBO_INTERNAL_ONLY
527 operator +=(T
const & value) & {
return operator +=(std::string_view(value)); }
528 template<
typename T>
typename libreoffice_internal::CharPtrDetector<T, OString &>::Type
529 operator +=(T
const &) && =
delete;
532 typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type
533 operator +=(T & value) & {
return operator +=(std::string_view(value)); }
535 typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type operator +=(T &) &&
538 template<
typename T>
typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
539 operator +=(T & literal) & {
540 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
543 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
544 libreoffice_internal::ConstCharArrayDetector<T>::length));
546 template<
typename T>
typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
547 operator +=(T &) && =
delete;
549 template<std::
size_t N> OString & operator +=(OStringLiteral<N>
const & literal) &
550 {
return operator +=(std::string_view(literal.getStr(), literal.getLength())); }
551 template<std::
size_t N>
void operator +=(OStringLiteral<N>
const &) && =
delete;
553 OString & operator +=(std::string_view sv) & {
557 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max() - pData->length)) {
558 throw std::bad_alloc();
560 auto const l = pData->length + sv.size();
562 *addDataHelper(pData->buffer + pData->length, sv.data(), sv.size()) =
'\0';
566 void operator +=(std::string_view) && =
delete;
569 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
574 template<
typename T1,
typename T2 >
575 OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
576 sal_Int32 l = c.length();
581 char* end = c.addData( pData->buffer + pData->length );
586 template<
typename T1,
typename T2>
void operator +=(
587 OStringConcat<T1, T2> &&) && =
delete;
593 template<
typename T, std::
size_t N >
594 OString& operator+=( StringNumberBase< char, T, N >&& n ) & {
595 return operator +=(std::string_view(n.buf, n.length));
597 template<
typename T, std::
size_t N>
void operator +=(
598 StringNumberBase<char, T, N> &&) && =
delete;
630 return pData->length == 0;
644 const char *
getStr() const SAL_RETURNS_NONNULL {
return pData->buffer; }
655 char operator [](sal_Int32 index)
const {
657 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
658 return getStr()[index];
695 rObj.
pData->buffer, rObj.
pData->length, maxLength );
729 if ( pData->length != str.
pData->length )
731 if ( pData == str.
pData )
751 bool equalsL(
const char* value, sal_Int32 length )
const
753 if ( pData->length != length )
757 value, length ) == 0;
774 #if defined LIBO_INTERNAL_ONLY
775 bool equalsIgnoreAsciiCase( std::string_view str )
const
777 if ( sal_uInt32(pData->length) != str.size() )
779 if ( pData->buffer == str.data() )
782 str.data(), str.size() ) == 0;
787 if ( pData->length != str.
pData->length )
789 if ( pData == str.
pData )
817 template<
typename T >
823 template<
typename T >
834 template<
typename T >
837 RTL_STRING_CONST_FUNCTION
844 pData->buffer, pData->length,
872 if ( pData->length != asciiStrLength )
876 asciiStr, asciiStrLength ) == 0;
894 #if defined LIBO_INTERNAL_ONLY
895 bool match( std::string_view str, sal_Int32 fromIndex = 0 )
const
898 str.data(), str.size(), str.size() ) == 0;
913 template<
typename T >
916 RTL_STRING_CONST_FUNCTION
921 pData->buffer + fromIndex, pData->length - fromIndex,
946 char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
950 pData->buffer + fromIndex, pData->length - fromIndex,
951 str, strLength, strLength) == 0;
958 #if SAL_TYPES_SIZEOFLONG == 8
980 #if defined LIBO_INTERNAL_ONLY
981 bool matchIgnoreAsciiCase( std::string_view str, sal_Int32 fromIndex = 0 )
const
984 str.data(), str.size(),
992 str.
pData->length ) == 0;
1000 template<
typename T >
1003 RTL_STRING_CONST_FUNCTION
1008 pData->buffer+fromIndex, pData->length-fromIndex,
1030 #if defined LIBO_INTERNAL_ONLY
1031 bool startsWith(std::string_view str,
OString * rest = NULL)
const {
1032 bool b = match(str);
1033 if (b && rest != NULL) {
1034 *rest = copy(str.size());
1040 bool b = match(str);
1041 if (b && rest != NULL) {
1053 template<
typename T >
1055 T & literal,
OString * rest = NULL)
const
1057 RTL_STRING_CONST_FUNCTION
1058 bool b = match(literal, 0);
1059 if (b && rest != NULL) {
1085 #if defined LIBO_INTERNAL_ONLY
1086 bool startsWithIgnoreAsciiCase(std::string_view str,
OString * rest = NULL)
1089 bool b = matchIgnoreAsciiCase(str);
1090 if (b && rest != NULL) {
1091 *rest = copy(str.size());
1099 bool b = matchIgnoreAsciiCase(str);
1100 if (b && rest != NULL) {
1112 template<
typename T >
1116 RTL_STRING_CONST_FUNCTION
1119 bool b = matchIgnoreAsciiCase(literal);
1120 if (b && rest != NULL) {
1141 #if defined LIBO_INTERNAL_ONLY
1142 bool endsWith(std::string_view str,
OString * rest = NULL)
const {
1143 bool b = str.size() <= sal_uInt32(getLength())
1144 && match(str, getLength() - str.size());
1145 if (b && rest != NULL) {
1146 *rest = copy(0, getLength() - str.size());
1153 && match(str, getLength() - str.
getLength());
1154 if (b && rest != NULL) {
1155 *rest = copy(0, getLength() - str.
getLength());
1166 template<
typename T >
1168 T & literal,
OString * rest = NULL)
const
1170 RTL_STRING_CONST_FUNCTION
1175 <= sal_uInt32(getLength()))
1181 if (b && rest != NULL) {
1203 bool endsWithL(
char const * str, sal_Int32 strLength)
const {
1204 return strLength <= getLength()
1205 && matchL(str, strLength, getLength() - strLength);
1209 {
return rStr1.
equals(rStr2); }
1213 {
return rStr1.
compareTo( rStr2 ) < 0; }
1215 {
return rStr1.
compareTo( rStr2 ) > 0; }
1217 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1219 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1221 template<
typename T >
1230 template<
typename T >
1239 template<
typename T >
1248 template<
typename T >
1262 template<
typename T >
1265 RTL_STRING_CONST_FUNCTION
1284 template<
typename T >
1287 RTL_STRING_CONST_FUNCTION
1301 template<
typename T >
1307 template<
typename T >
1313 template<
typename T >
1319 template<
typename T >
1330 template<
typename T >
1333 return !( rStr == literal );
1341 template<
typename T >
1344 return !( literal == rStr );
1372 sal_Int32
indexOf(
char ch, sal_Int32 fromIndex = 0 )
const
1375 return (ret < 0 ? ret : ret+fromIndex);
1424 #if defined LIBO_INTERNAL_ONLY
1425 sal_Int32 indexOf( std::string_view str, sal_Int32 fromIndex = 0 )
const
1428 str.data(), str.size() );
1429 return (ret < 0 ? ret : ret+fromIndex);
1436 return (ret < 0 ? ret : ret+fromIndex);
1444 template<
typename T >
1447 RTL_STRING_CONST_FUNCTION
1451 pData->buffer + fromIndex, pData->length - fromIndex,
1454 return n < 0 ? n : n + fromIndex;
1475 sal_Int32
indexOfL(
char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1479 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1480 return n < 0 ? n : n + fromIndex;
1487 #if SAL_TYPES_SIZEOFLONG == 8
1506 #if defined LIBO_INTERNAL_ONLY
1507 sal_Int32 lastIndexOf( std::string_view str )
const
1510 str.data(), str.size() );
1537 #if defined LIBO_INTERNAL_ONLY
1538 sal_Int32 lastIndexOf( std::string_view str, sal_Int32 fromIndex )
const
1541 str.data(), str.size() );
1563 return copy(beginIndex, getLength() - beginIndex);
1580 rtl_String *pNew = NULL;
1585 #if defined LIBO_INTERNAL_ONLY
1598 assert(beginIndex >= 0);
1599 assert(beginIndex <= getLength());
1600 return subView(beginIndex, getLength() - beginIndex);
1617 assert(beginIndex >= 0);
1619 assert(beginIndex <= getLength());
1620 assert(count <= getLength() - beginIndex);
1621 return std::string_view(*this).substr(beginIndex, count);
1632 std::vector<std::string_view> output;
1633 std::string_view stringView(*
this);
1637 index = stringView.find(separator);
1638 if (index != stringView.npos)
1641 output.push_back(stringView.substr(0, index));
1643 if (index != stringView.length() - separator.length())
1644 stringView = stringView.substr(index + separator.length(),
1645 stringView.length() - index - separator.length());
1647 index = stringView.npos;
1650 output.push_back(stringView);
1651 }
while (index != stringView.npos);
1657 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1668 rtl_String* pNew = NULL;
1674 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1677 return str1.
concat( str2 );
1682 #ifndef LIBO_INTERNAL_ONLY
1698 rtl_String* pNew = NULL;
1704 #ifdef LIBO_INTERNAL_ONLY
1707 rtl_String* pNew = NULL;
1708 rtl_string_newReplaceStrAt_WithLength ( &pNew, pData, index, count, newStr.data(), newStr.size() );
1728 rtl_String* pNew = NULL;
1752 OString const & from,
OString const & to, sal_Int32 * index = NULL)
const
1754 rtl_String * s = NULL;
1757 &s, pData, from.
pData->buffer, from.
pData->length,
1758 to.
pData->buffer, to.
pData->length, index == NULL ? &i : index);
1776 rtl_String * s = NULL;
1778 &s, pData, from.
pData->buffer, from.
pData->length,
1795 rtl_String* pNew = NULL;
1812 rtl_String* pNew = NULL;
1830 rtl_String* pNew = NULL;
1861 rtl_String * pNew = NULL;
1881 return getToken(count, separator, n);
1905 return pData->buffer[0];
1998 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2000 static OStringNumber< int > number(
int i, sal_Int16 radix = 10 )
2002 return OStringNumber< int >( i, radix );
2004 static OStringNumber< long long > number(
long long ll, sal_Int16 radix = 10 )
2006 return OStringNumber< long long >( ll, radix );
2008 static OStringNumber< unsigned long long > number(
unsigned long long ll, sal_Int16 radix = 10 )
2010 return OStringNumber< unsigned long long >( ll, radix );
2012 static OStringNumber< unsigned long long > number(
unsigned int i, sal_Int16 radix = 10 )
2014 return number( static_cast< unsigned long long >( i ), radix );
2016 static OStringNumber< long long > number(
long i, sal_Int16 radix = 10)
2018 return number( static_cast< long long >( i ), radix );
2020 static OStringNumber< unsigned long long > number(
unsigned long i, sal_Int16 radix = 10 )
2022 return number( static_cast< unsigned long long >( i ), radix );
2024 static OStringNumber< float > number(
float f )
2026 return OStringNumber< float >( f );
2028 static OStringNumber< double > number(
double d )
2030 return OStringNumber< double >( d );
2052 return number( static_cast< unsigned long long >( i ), radix );
2058 return number( static_cast< long long >( i ), radix );
2064 return number( static_cast< unsigned long long >( i ), radix );
2169 return number( i, radix );
2184 return number( ll, radix );
2215 #if defined LIBO_INTERNAL_ONLY
2216 operator std::string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
2219 #if defined LIBO_INTERNAL_ONLY
2230 template<
typename T> [[nodiscard]]
static
2231 OStringConcat<OStringConcatMarker, T>
2232 Concat(T
const & value) {
return OStringConcat<OStringConcatMarker, T>({}, value); }
2237 template<
typename T, std::
size_t N> [[nodiscard]]
static
2238 OStringConcat<OStringConcatMarker, T[N]>
2239 Concat(T (& value)[N]) {
return OStringConcat<OStringConcatMarker, T[N]>({}, value); }
2243 #if defined LIBO_INTERNAL_ONLY
2245 inline OStringConstExpr::operator
const OString &()
const {
return OString::unacquired(&pData); }
2248 #if defined LIBO_INTERNAL_ONLY
2249 inline bool operator ==(OString
const & lhs, StringConcatenation<char>
const & rhs)
2250 {
return lhs == std::string_view(rhs); }
2251 inline bool operator !=(OString
const & lhs, StringConcatenation<char>
const & rhs)
2252 {
return lhs != std::string_view(rhs); }
2253 inline bool operator ==(StringConcatenation<char>
const & lhs, OString
const & rhs)
2254 {
return std::string_view(lhs) == rhs; }
2255 inline bool operator !=(StringConcatenation<char>
const & lhs, OString
const & rhs)
2256 {
return std::string_view(lhs) != rhs; }
2261 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2267 struct ToStringHelper< OString >
2269 static std::size_t length(
const OString& s ) {
return s.getLength(); }
2270 char* operator()(
char* buffer,
const OString& s )
const {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
2276 template<std::
size_t N>
2277 struct ToStringHelper< OStringLiteral<N> >
2279 static constexpr std::size_t length(
const OStringLiteral<N>& str ) {
return str.getLength(); }
2280 char* operator()(
char* buffer,
const OStringLiteral<N>& str )
const {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
2286 template<
typename charT,
typename traits,
typename T1,
typename T2 >
2287 inline std::basic_ostream<charT, traits> &
operator <<(
2288 std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
2290 return stream << OString( std::move(concat) );
2312 {
return static_cast<size_t>(rString.
hashCode()); }
2337 template<
typename charT,
typename traits > std::basic_ostream<charT, traits> &
2339 std::basic_ostream<charT, traits> & stream,
OString const & rString)
2341 return stream << rString.
getStr();
2347 #ifdef RTL_STRING_UNITTEST
2350 typedef rtlunittest::OString OString;
2352 #undef RTL_STRING_CONST_FUNCTION
2355 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2356 using ::rtl::OString;
2357 using ::rtl::OStringChar;
2358 using ::rtl::Concat2View;
2359 using ::rtl::OStringHash;
2360 using ::rtl::OStringLiteral;
2369 #if defined LIBO_INTERNAL_ONLY
2377 if constexpr (
sizeof(std::size_t) == 8)
2381 for (sal_Int32 i = 0, len = s.
getLength(); i < len; ++i)
2395 #endif // INCLUDED_RTL_STRING_HXX
sal_Int32 lastIndexOf(char 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: string.hxx:1404
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:657
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:611
SAL_WARN_UNUSED_RESULT OString replaceAll(OString const &from, OString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: string.hxx:1775
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:785
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:1240
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:2043
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1666
SAL_DLLPUBLIC void rtl_string_newFromSubString(rtl_String **newStr, const rtl_String *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, char oldChar, char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:818
bool equalsL(const char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:751
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
static OString 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: string.hxx:2050
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:1222
unsigned char sal_Bool
Definition: types.h:18
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1285
SAL_DLLPUBLIC void rtl_string_newTrim(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1918
static OString 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: string.hxx:2068
SAL_DLLPUBLIC void rtl_string_newToAsciiLowerCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:945
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
bool startsWithIgnoreAsciiCase(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: string.hxx:1096
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1578
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:1249
pData
New string from a character buffer array.
Definition: string.hxx:289
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:17
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:1151
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:634
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1892
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC void rtl_string_newReplaceStrAt(rtl_String **newStr, rtl_String *str, sal_Int32 idx, sal_Int32 count, rtl_String *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1561
OString()
New string containing no characters.
Definition: string.hxx:206
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:673
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1354
__sal_NoAcquire
Definition: types.h:332
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:1039
SAL_DLLPUBLIC void rtl_uString2String(rtl_String **newStr, const sal_Unicode *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new byte string by converting a Unicode string, using a specific text encoding.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1263
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:644
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
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: string.hxx:1001
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: string.hxx:914
Definition: stringutils.hxx:194
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1342
sal_uInt16 sal_Unicode
Definition: types.h:103
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:73
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1338
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1993
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:618
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:196
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:824
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:243
bool matchIgnoreAsciiCase(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: string.hxx:988
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:256
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:2090
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:727
char toChar() const
Returns the first character from this string.
Definition: string.hxx:1903
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:83
libreoffice_internal::ConstCharArrayDetector< T, OString & >::Type operator=(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:491
static OString 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: string.hxx:2062
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1114
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:695
SAL_DLLPUBLIC void rtl_string_newConcat(rtl_String **newStr, rtl_String *left, rtl_String *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:462
bool equalsIgnoreAsciiCaseL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:870
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:454
sal_Int32 indexOfL(char const *str, sal_Int32 len, 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: string.hxx:1475
SAL_WARN_UNUSED_RESULT OString replaceAt(sal_Int32 index, sal_Int32 count, const OString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: string.hxx:1696
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:569
Definition: stringutils.hxx:166
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
SAL_DLLPUBLIC void rtl_string_ensureCapacity(rtl_String **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1331
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1980
SAL_DLLPUBLIC void rtl_string_newReplaceAll(rtl_String **newStr, rtl_String *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_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OString(const OString &str)
New string from OString.
Definition: string.hxx:217
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:2139
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1967
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
OString(const sal_Unicode *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
New string from a Unicode character buffer array.
Definition: string.hxx:390
static OString 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: string.hxx:2075
Definition: stringutils.hxx:142
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:710
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:1203
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:2318
SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: string.hxx:1810
SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: string.hxx:1793
SAL_DLLPUBLIC double rtl_str_toDouble(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:692
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1950
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
OString getToken(sal_Int32 token, char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1859
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
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const char *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...
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
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: string.hxx:835
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:605
static OString number(long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:2056
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1675
SAL_WARN_UNUSED_RESULT OString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: string.hxx:1828
OString(char value)
New string from a single character.
Definition: string.hxx:266
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:676
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:628
SAL_DLLPUBLIC float rtl_str_toFloat(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:2311
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:1231
sal_Int32 lastIndexOf(const OString &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: string.hxx:1544
SAL_WARN_UNUSED_RESULT OString replaceFirst(OString const &from, OString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: string.hxx:1751
SAL_DLLPUBLIC void rtl_string_newReplaceFirst(rtl_String **newStr, rtl_String *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:2105
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1054
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1302
sal_Int32 lastIndexOf(char ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: string.hxx:1387
A helper to use OStrings with hash maps.
Definition: string.hxx:2300
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2323
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:513
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: string.hxx:1445
~OString()
Release the string data.
Definition: string.hxx:436
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1314
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1935
Definition: stringutils.hxx:140
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: string.hxx:1513
SAL_WARN_UNUSED_RESULT OString replace(char oldChar, char newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: string.hxx:1726
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1167
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1879
OString(const char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:347
sal_Int32 indexOf(char 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: string.hxx:1372
sal_Int32 indexOf(const OString &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: string.hxx:1432
size_t operator()(const char *p) const
Definition: string.hxx:2325
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1308
SAL_DLLPUBLIC void rtl_string_newToAsciiUpperCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:901
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1320
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2316