20 #ifndef INCLUDED_RTL_STRING_HXX
21 #define INCLUDED_RTL_STRING_HXX
34 #if defined LIBO_INTERNAL_ONLY
35 #include <string_view>
36 #include <type_traits>
43 #ifdef LIBO_INTERNAL_ONLY
44 #include "config_global.h"
45 #include "rtl/stringconcat.hxx"
48 #ifdef RTL_STRING_UNITTEST
49 extern bool rtl_string_unittest_const_literal;
50 extern bool rtl_string_unittest_const_literal_function;
58 #ifdef RTL_STRING_UNITTEST
59 #define rtl rtlunittest
66 #ifdef RTL_STRING_UNITTEST
69 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
71 #define RTL_STRING_CONST_FUNCTION
75 #ifdef LIBO_INTERNAL_ONLY
82 template<std::size_t N> class SAL_WARN_UNUSED OStringLiteral {
83 static_assert(N != 0);
84 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(),
"literal too long");
87 #if HAVE_CPP_CONSTEVAL
92 explicit OStringLiteral(
char const (&literal)[N]) {
94 assert(literal[N - 1] ==
'\0');
96 for (std::size_t i = 0; i != N; ++i) {
97 buffer[i] = literal[i];
101 #if defined __cpp_char8_t
102 #if HAVE_CPP_CONSTEVAL
107 explicit OStringLiteral(char8_t
const (&literal)[N]) {
109 assert(literal[N - 1] ==
'\0');
111 for (std::size_t i = 0; i != N; ++i) {
112 buffer[i] = literal[i];
117 constexpr sal_Int32 getLength()
const {
return length; }
119 constexpr
char const * getStr()
const SAL_RETURNS_NONNULL {
return buffer; }
122 static constexpr
void assertLayout() {
125 static_assert(offsetof(OStringLiteral, refCount) == offsetof(rtl_String, refCount));
127 std::is_same_v<decltype(refCount), decltype(rtl_String::refCount)>);
128 static_assert(offsetof(OStringLiteral, length) == offsetof(rtl_String, length));
129 static_assert(std::is_same_v<decltype(length), decltype(rtl_String::length)>);
130 static_assert(offsetof(OStringLiteral, buffer) == offsetof(rtl_String, buffer));
133 std::remove_extent_t<decltype(buffer)>,
134 std::remove_extent_t<decltype(rtl_String::buffer)>>);
139 sal_Int32 length = N - 1;
197 #if defined LIBO_INTERNAL_ONLY
254 template<
typename T >
261 template<
typename T >
278 template<
typename T >
293 #ifdef RTL_STRING_UNITTEST
294 rtl_string_unittest_const_literal =
true;
306 OString(
const char * value, sal_Int32 length )
312 #ifdef LIBO_INTERNAL_ONLY
319 template<std::
size_t N>
OString(OStringLiteral<N>
const & literal):
320 pData(const_cast<rtl_String *>(reinterpret_cast<rtl_String const *>(&literal))) {}
321 template<std::
size_t N> OString(OStringLiteral<N> &&) =
delete;
325 #if defined LIBO_INTERNAL_ONLY
326 OString(std::string_view sv) {
327 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
328 throw std::bad_alloc();
356 throw std::bad_alloc();
360 #ifdef LIBO_INTERNAL_ONLY
365 template< typename T1, typename T2 >
366 OString( OStringConcat< T1, T2 >&& c )
368 const sal_Int32 l = c.length();
372 char* end = c.addData( pData->buffer );
382 template<
typename T >
383 OString( OStringNumber< T >&& n )
384 : OString( n.buf, n.length )
388 #ifdef LIBO_INTERNAL_ONLY
389 OString(std::nullptr_t) =
delete;
411 #if defined LIBO_INTERNAL_ONLY
433 template<
typename T >
436 RTL_STRING_CONST_FUNCTION
457 #if defined LIBO_INTERNAL_ONLY
464 #if defined LIBO_INTERNAL_ONLY
465 void operator+=(
OString const &) && =
delete;
468 #ifdef LIBO_INTERNAL_ONLY
473 template< typename T1, typename T2 >
474 OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
475 sal_Int32 l = c.length();
480 char* end = c.addData( pData->buffer + pData->length );
485 template<
typename T1,
typename T2>
void operator +=(
486 OStringConcat<T1, T2> &&) && =
delete;
492 template<
typename T >
493 OString& operator+=( OStringNumber< T >&& n ) & {
494 sal_Int32 l = n.length;
499 char* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
504 template<
typename T>
void operator +=(
505 OStringNumber<T> &&) && =
delete;
537 return pData->length == 0;
551 const char *
getStr() const SAL_RETURNS_NONNULL {
return pData->buffer; }
562 char operator [](sal_Int32 index)
const {
564 assert(index >= 0 &&
static_cast<sal_uInt32
>(index) <
static_cast<sal_uInt32
>(getLength()));
565 return getStr()[index];
583 str.pData->buffer, str.pData->length );
602 rObj.pData->buffer, rObj.pData->length, maxLength );
620 str.pData->buffer, str.pData->length );
636 if ( pData->length != str.pData->length )
638 if ( pData == str.pData )
641 str.pData->buffer, str.pData->length ) == 0;
659 bool equalsL(
const char* value, sal_Int32 length )
const
661 if ( pData->length != length )
665 value, length ) == 0;
684 if ( pData->length != str.pData->length )
686 if ( pData == str.pData )
689 str.pData->buffer, str.pData->length ) == 0;
713 template<
typename T >
719 template<
typename T >
730 template<
typename T >
733 RTL_STRING_CONST_FUNCTION
740 pData->buffer, pData->length,
768 if ( pData->length != asciiStrLength )
772 asciiStr, asciiStrLength ) == 0;
793 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
801 template<
typename T >
804 RTL_STRING_CONST_FUNCTION
809 pData->buffer + fromIndex, pData->length - fromIndex,
834 char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
838 pData->buffer + fromIndex, pData->length - fromIndex,
839 str, strLength, strLength) == 0;
846 #if SAL_TYPES_SIZEOFLONG == 8
871 str.pData->buffer, str.pData->length,
872 str.pData->length ) == 0;
880 template<
typename T >
883 RTL_STRING_CONST_FUNCTION
888 pData->buffer+fromIndex, pData->length-fromIndex,
912 if (b && rest != NULL) {
923 template<
typename T >
925 T & literal,
OString * rest = NULL)
const
927 RTL_STRING_CONST_FUNCTION
928 bool b = match(literal, 0);
929 if (b && rest != NULL) {
958 bool b = matchIgnoreAsciiCase(str);
959 if (b && rest != NULL) {
970 template<
typename T >
974 RTL_STRING_CONST_FUNCTION
977 bool b = matchIgnoreAsciiCase(literal);
978 if (b && rest != NULL) {
1001 && match(str, getLength() - str.
getLength());
1002 if (b && rest != NULL) {
1003 *rest = copy(0, getLength() - str.
getLength());
1013 template<
typename T >
1015 T & literal,
OString * rest = NULL)
const
1017 RTL_STRING_CONST_FUNCTION
1022 <= sal_uInt32(getLength()))
1028 if (b && rest != NULL) {
1050 bool endsWithL(
char const * str, sal_Int32 strLength)
const {
1051 return strLength <= getLength()
1052 && matchL(str, strLength, getLength() - strLength);
1056 {
return rStr1.
equals(rStr2); }
1060 {
return rStr1.
compareTo( rStr2 ) < 0; }
1062 {
return rStr1.
compareTo( rStr2 ) > 0; }
1064 {
return rStr1.
compareTo( rStr2 ) <= 0; }
1066 {
return rStr1.
compareTo( rStr2 ) >= 0; }
1068 template<
typename T >
1074 template<
typename T >
1080 template<
typename T >
1086 template<
typename T >
1097 template<
typename T >
1100 RTL_STRING_CONST_FUNCTION
1107 rStr.pData->buffer, rStr.pData->length,
1119 template<
typename T >
1122 RTL_STRING_CONST_FUNCTION
1129 rStr.pData->buffer, rStr.pData->length,
1136 template<
typename T >
1142 template<
typename T >
1148 template<
typename T >
1154 template<
typename T >
1165 template<
typename T >
1168 return !( rStr == literal );
1176 template<
typename T >
1179 return !( literal == rStr );
1207 sal_Int32
indexOf(
char ch, sal_Int32 fromIndex = 0 )
const
1210 return (ret < 0 ? ret : ret+fromIndex);
1262 str.pData->buffer, str.pData->length );
1263 return (ret < 0 ? ret : ret+fromIndex);
1271 template<
typename T >
1274 RTL_STRING_CONST_FUNCTION
1278 pData->buffer + fromIndex, pData->length - fromIndex,
1281 return n < 0 ? n : n + fromIndex;
1302 sal_Int32
indexOfL(
char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1306 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1307 return n < 0 ? n : n + fromIndex;
1314 #if SAL_TYPES_SIZEOFLONG == 8
1336 str.pData->buffer, str.pData->length );
1359 str.pData->buffer, str.pData->length );
1374 return copy(beginIndex, getLength() - beginIndex);
1391 rtl_String *pNew = NULL;
1396 #if defined LIBO_INTERNAL_ONLY
1409 assert(beginIndex >= 0);
1410 assert(beginIndex <= getLength());
1411 return subView(beginIndex, getLength() - beginIndex);
1428 assert(beginIndex >= 0);
1430 assert(beginIndex <= getLength());
1431 assert(count <= getLength() - beginIndex);
1432 return std::string_view(*this).substr(beginIndex, count);
1436 #ifndef LIBO_INTERNAL_ONLY
1445 SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const
1447 rtl_String* pNew = NULL;
1453 #ifndef LIBO_INTERNAL_ONLY
1456 return str1.
concat( str2 );
1475 rtl_String* pNew = NULL;
1495 rtl_String* pNew = NULL;
1519 OString const & from,
OString const & to, sal_Int32 * index = NULL)
const
1521 rtl_String * s = NULL;
1524 &s, pData, from.pData->buffer, from.pData->length,
1525 to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1543 rtl_String * s = NULL;
1545 &s, pData, from.pData->buffer, from.pData->length,
1546 to.pData->buffer, to.pData->length);
1562 rtl_String* pNew = NULL;
1579 rtl_String* pNew = NULL;
1597 rtl_String* pNew = NULL;
1628 rtl_String * pNew = NULL;
1648 return getToken(count, separator, n);
1672 return pData->buffer[0];
1765 #ifdef LIBO_INTERNAL_ONLY
1767 static OStringNumber< int > number(
int i, sal_Int16 radix = 10 )
1769 return OStringNumber< int >( i, radix );
1771 static OStringNumber< long long > number(
long long ll, sal_Int16 radix = 10 )
1773 return OStringNumber< long long >( ll, radix );
1775 static OStringNumber< unsigned long long > number(
unsigned long long ll, sal_Int16 radix = 10 )
1777 return OStringNumber< unsigned long long >( ll, radix );
1779 static OStringNumber< unsigned long long > number(
unsigned int i, sal_Int16 radix = 10 )
1781 return number(
static_cast< unsigned long long >( i ), radix );
1783 static OStringNumber< long long > number(
long i, sal_Int16 radix = 10)
1785 return number(
static_cast< long long >( i ), radix );
1787 static OStringNumber< unsigned long long > number(
unsigned long i, sal_Int16 radix = 10 )
1789 return number(
static_cast< unsigned long long >( i ), radix );
1791 static OStringNumber< float > number(
float f )
1793 return OStringNumber< float >( f );
1795 static OStringNumber< double > number(
double d )
1797 return OStringNumber< double >( d );
1819 return number(
static_cast< unsigned long long >( i ), radix );
1825 return number(
static_cast< long long >( i ), radix );
1831 return number(
static_cast< unsigned long long >( i ), radix );
1936 return number( i, radix );
1951 return number( ll, radix );
1982 #if defined LIBO_INTERNAL_ONLY
1983 operator std::string_view()
const {
return {getStr(), sal_uInt32(getLength())}; }
1986 #if defined LIBO_INTERNAL_ONLY
1997 template<
typename T> [[nodiscard]]
static
1998 typename std::enable_if_t<
1999 ToStringHelper<T>::allowOStringConcat, OStringConcat<OStringConcatMarker, T>>
2000 Concat(T
const & value) {
return OStringConcat<OStringConcatMarker, T>({}, value); }
2005 template<
typename T, std::
size_t N> [[nodiscard]]
static
2006 typename std::enable_if_t<
2007 ToStringHelper<T[N]>::allowOStringConcat, OStringConcat<OStringConcatMarker, T[N]>>
2008 Concat(T (& value)[N]) {
return OStringConcat<OStringConcatMarker, T[N]>({}, value); }
2014 #ifdef LIBO_INTERNAL_ONLY
2020 struct ToStringHelper< OString >
2022 static std::size_t length(
const OString& s ) {
return s.getLength(); }
2023 static char* addData(
char* buffer,
const OString& s ) {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
2024 static const bool allowOStringConcat =
true;
2025 static const bool allowOUStringConcat =
false;
2031 template<std::
size_t N>
2032 struct ToStringHelper< OStringLiteral<N> >
2034 static constexpr std::size_t length(
const OStringLiteral<N>& str ) {
return str.getLength(); }
2035 static char* addData(
char* buffer,
const OStringLiteral<N>& str ) {
return addDataHelper( buffer, str.getStr(), str.getLength() ); }
2036 static const bool allowOStringConcat =
true;
2037 static const bool allowOUStringConcat =
false;
2043 template<
typename charT,
typename traits,
typename T1,
typename T2 >
2044 inline std::basic_ostream<charT, traits> &
operator <<(
2045 std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
2047 return stream << OString( std::move(concat) );
2069 {
return static_cast<size_t>(rString.
hashCode()); }
2094 template<
typename charT,
typename traits > std::basic_ostream<charT, traits> &
2096 std::basic_ostream<charT, traits> & stream, OString
const & rString)
2098 return stream << rString.getStr();
2104 #ifdef RTL_STRING_UNITTEST
2107 typedef rtlunittest::OString OString;
2109 #undef RTL_STRING_CONST_FUNCTION
2112 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2113 using ::rtl::OString;
2114 using ::rtl::OStringChar;
2115 using ::rtl::OStringHash;
2116 using ::rtl::OStringLiteral;
2125 #if defined LIBO_INTERNAL_ONLY
2132 {
return std::size_t(s.
hashCode()); }
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:445
__sal_NoAcquire
Definition: types.h:349
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:352
unsigned char sal_Bool
Definition: types.h:34
sal_uInt16 sal_Unicode
Definition: types.h:119
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:280
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:558
SAL_DLLPUBLIC double rtl_str_toDouble(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
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 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_DLLPUBLIC sal_Bool rtl_str_toBoolean(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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.
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_compareIgnoreAsciiCase(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
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_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.
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.
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_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.
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.
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.
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_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 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.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
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.
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_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.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
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.
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
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 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 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_DLLPUBLIC sal_Int32 rtl_str_toInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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.
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
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 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_valueOfUInt64(char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
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.
SAL_DLLPUBLIC float rtl_str_toFloat(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
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.
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 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.
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.
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.
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
sal_Int32 oslInterlockedCount
Definition: interlck.h:40
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
Definition: bootstrap.hxx:30
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros,...
Definition: string.hxx:2095
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:664
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:171
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1445
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:279
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:349
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:1014
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:456
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:1829
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:910
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:1098
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:924
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:1120
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:1272
OString(const char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:306
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:1842
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1810
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1734
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,...
Definition: string.hxx:1302
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:580
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:731
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:1577
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:972
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:1177
char toChar() const
Returns the first character from this string.
Definition: string.hxx:1670
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1659
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1454
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1372
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1143
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:217
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:955
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:1835
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1333
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:512
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:1518
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1646
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:1817
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:881
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:599
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:535
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:1087
OString(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a character buffer array.
Definition: string.hxx:255
OString getToken(sal_Int32 token, char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1626
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:617
sal_Int32 lastIndexOf(const OString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1356
sal_Int32 lastIndexOf(char ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1222
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:1389
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1137
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:1493
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1189
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1906
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:833
bool equalsL(const char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:659
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:1595
OString(const OString &str)
New string from OString.
Definition: string.hxx:191
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:1542
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:1050
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:1560
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:790
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:551
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:434
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1747
OString()
New string containing no characters.
Definition: string.hxx:180
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:802
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:1081
OString(char value)
New string from a single character.
Definition: string.hxx:240
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:1823
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:682
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1717
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,...
Definition: string.hxx:1259
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1685
~OString()
Release the string data.
Definition: string.hxx:395
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:720
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:1166
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:405
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:714
sal_Int32 indexOf(char ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character,...
Definition: string.hxx:1207
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:1473
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:525
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1760
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1872
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:999
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:634
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:1075
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:230
sal_Int32 lastIndexOf(char ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1239
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:262
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:1069
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1702
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1857
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1149
bool equalsIgnoreAsciiCaseL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:766
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:868
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1155
A helper to use OStrings with hash maps.
Definition: string.hxx:2058
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:2068
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2074
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:2075
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2081
size_t operator()(const char *p) const
Definition: string.hxx:2082
Definition: stringutils.hxx:131
Definition: stringutils.hxx:134
Definition: stringutils.hxx:158
Definition: stringutils.hxx:186