LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Friends | List of all members
rtl::OUString Class Reference

This String class provides base functionality for C++ like Unicode character array handling. More...

#include <ustring.hxx>

Public Member Functions

 OUString ()
 New string containing no characters. More...
 
 OUString (const OUString &str)
 New string from OUString. More...
 
 OUString (rtl_uString *str)
 New string from OUString data. More...
 
 OUString (rtl_uString *str, __sal_NoAcquire)
 New OUString from OUString data without acquiring it. More...
 
 OUString (sal_Unicode value)
 New string from a single Unicode character. More...
 
 OUString (const sal_Unicode *value)
 New string from a Unicode character buffer array. More...
 
 OUString (const sal_Unicode *value, sal_Int32 length)
 New string from a Unicode character buffer array. More...
 
template<typename T >
 OUString (T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
 New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set (i.e. More...
 
 OUString (const sal_Char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
 New string from an 8-Bit character buffer array. More...
 
 OUString (sal_uInt32 const *codePoints, sal_Int32 codePointCount)
 Create a new string from an array of Unicode code points. More...
 
 ~OUString ()
 Release the string data. More...
 
OUStringoperator= (const OUString &str)
 Assign a new string. More...
 
template<typename T >
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 ASCII set (i.e. More...
 
OUStringoperator+= (const OUString &str)
 Append a string to this string. More...
 
template<typename T >
libreoffice_internal::ConstCharArrayDetector
< T, OUString & >::Type 
operator+= (T &literal)
 Append an ASCII string literal to this string. More...
 
void clear ()
 Clears the string, i.e, makes a zero-character string. More...
 
sal_Int32 getLength () const
 Returns the length of this string. More...
 
bool isEmpty () const
 Checks if a string is empty. More...
 
const sal_UnicodegetStr () const
 Returns a pointer to the Unicode character buffer for this string. More...
 
sal_Unicode operator[] (sal_Int32 index) const
 Access to individual characters. More...
 
sal_Int32 compareTo (const OUString &str) const
 Compares two strings. More...
 
sal_Int32 compareTo (const OUString &str, sal_Int32 maxLength) const
 Compares two strings with a maximum count of characters. More...
 
sal_Int32 reverseCompareTo (const OUString &str) const
 Compares two strings in reverse order. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool equals (const OUString &str) const
 Perform a comparison of two strings. More...
 
bool equalsIgnoreAsciiCase (const OUString &str) const
 Perform a ASCII lowercase comparison of two strings. More...
 
sal_Int32 compareToIgnoreAsciiCase (const OUString &str) const
 Perform a ASCII lowercase comparison of two strings. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool match (const OUString &str, sal_Int32 fromIndex=0) const
 Match against a substring appearing in this string. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool matchIgnoreAsciiCase (const OUString &str, sal_Int32 fromIndex=0) const
 Match against a substring appearing in this string, ignoring the case of ASCII letters. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
sal_Int32 compareToAscii (const sal_Char *asciiStr) const
 Compares two strings. More...
 
sal_Int32 compareToAscii (const sal_Char *asciiStr, sal_Int32 maxLength) const
 Compares two strings with a maximum count of characters. More...
 
sal_Int32 reverseCompareToAsciiL (const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
 Compares two strings in reverse order. More...
 
bool equalsAscii (const sal_Char *asciiStr) const
 Perform a comparison of two strings. More...
 
bool equalsAsciiL (const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
 Perform a comparison of two strings. More...
 
bool equalsIgnoreAsciiCaseAscii (const sal_Char *asciiStr) const
 Perform a ASCII lowercase comparison of two strings. More...
 
sal_Int32 compareToIgnoreAsciiCaseAscii (const sal_Char *asciiStr) const
 Compares two ASCII strings ignoring case. More...
 
bool equalsIgnoreAsciiCaseAsciiL (const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
 Perform an ASCII lowercase comparison of two strings. More...
 
bool matchAsciiL (const sal_Char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
 Match against a substring appearing in this string. More...
 
bool matchIgnoreAsciiCaseAsciiL (const sal_Char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
 Match against a substring appearing in this string, ignoring the case of ASCII letters. More...
 
bool startsWith (OUString const &str, OUString *rest=NULL) const
 Check whether this string starts with a given substring. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool startsWithIgnoreAsciiCase (OUString const &str, OUString *rest=NULL) const
 Check whether this string starts with a given string, ignoring the case of ASCII letters. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool endsWith (OUString const &str, OUString *rest=NULL) const
 Check whether this string ends with a given substring. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
bool endsWithAsciiL (char const *asciiStr, sal_Int32 asciiStrLength) const
 Check whether this string ends with a given ASCII string. More...
 
bool endsWithIgnoreAsciiCase (OUString const &str, OUString *rest=NULL) const
 Check whether this string ends with a given string, ignoring the case of ASCII letters. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
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. More...
 
sal_Int32 hashCode () const
 Returns a hashcode for this string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
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, starting at the specified index. More...
 
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. More...
 
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. More...
 
template<typename T >
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 only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument. More...
 
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. More...
 
SAL_WARN_UNUSED_RESULT OUString copy (sal_Int32 beginIndex) const
 Returns a new string that is a substring of this string. More...
 
SAL_WARN_UNUSED_RESULT OUString copy (sal_Int32 beginIndex, sal_Int32 count) const
 Returns a new string that is a substring of this string. More...
 
SAL_WARN_UNUSED_RESULT OUString concat (const OUString &str) const
 Concatenates the specified string to the end of this string. More...
 
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 with newStr. More...
 
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. More...
 
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 substring. More...
 
template<typename T >
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 substring. More...
 
template<typename T >
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 substring. More...
 
template<typename T1 , typename T2 >
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 substring. More...
 
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 substring. More...
 
template<typename T >
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 substring. More...
 
template<typename T >
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 substring. More...
 
template<typename T1 , typename T2 >
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 substring. More...
 
SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase () const
 Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-122). More...
 
SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase () const
 Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-90). More...
 
SAL_WARN_UNUSED_RESULT OUString trim () const
 Returns a new string resulting from removing white space from both ends of the string. More...
 
OUString getToken (sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
 Returns a token in the string. More...
 
OUString getToken (sal_Int32 count, sal_Unicode separator) const
 Returns a token from the string. More...
 
bool toBoolean () const
 Returns the Boolean value from this string. More...
 
sal_Unicode toChar () const
 Returns the first character from this string. More...
 
sal_Int32 toInt32 (sal_Int16 radix=10) const
 Returns the int32 value from this string. More...
 
sal_uInt32 toUInt32 (sal_Int16 radix=10) const
 Returns the uint32 value from this string. More...
 
sal_Int64 toInt64 (sal_Int16 radix=10) const
 Returns the int64 value from this string. More...
 
sal_uInt64 toUInt64 (sal_Int16 radix=10) const
 Returns the uint64 value from this string. More...
 
float toFloat () const
 Returns the float value from this string. More...
 
double toDouble () const
 Returns the double value from this string. More...
 
OUString intern () const
 Return a canonical representation for a string. More...
 
bool convertToString (OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
 Converts to an OString, signalling failure. More...
 
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. More...
 
OString toUtf8 () const
 Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully. More...
 

Static Public Member Functions

static OUString const & unacquired (rtl_uString *const *ppHandle)
 Provides an OUString const & passing a storage pointer of an rtl_uString * handle. More...
 
static OUString intern (const sal_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. More...
 
static OUString fromUtf8 (const OString &rSource)
 Convert an OString to an OUString, assuming that the OString is UTF-8-encoded. More...
 
static OUString number (int i, sal_Int16 radix=10)
 Returns the string representation of the integer argument. More...
 
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 only in what argument(s) it accepts. More...
 
static OUString number (long i, sal_Int16 radix=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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 only in what argument(s) it accepts. More...
 
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 only in what argument(s) it accepts. More...
 
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 only in what argument(s) it accepts. More...
 
static OUString number (float f)
 Returns the string representation of the float argument. More...
 
static OUString number (double d)
 Returns the string representation of the double argument. More...
 
static OUString valueOf (sal_Bool b)
 Returns the string representation of the sal_Bool argument. More...
 
static OUString boolean (bool b)
 Returns the string representation of the boolean argument. More...
 
static OUString valueOf (sal_Unicode c)
 Returns the string representation of the char argument. More...
 
static OUString valueOf (sal_Int32 i, sal_Int16 radix=10)
 Returns the string representation of the int argument. More...
 
static OUString valueOf (sal_Int64 ll, sal_Int16 radix=10)
 Returns the string representation of the long argument. More...
 
static OUString valueOf (float f)
 Returns the string representation of the float argument. More...
 
static OUString valueOf (double d)
 Returns the string representation of the double argument. More...
 
static OUString createFromAscii (const sal_Char *value)
 Returns a OUString copied without conversion from an ASCII character string. More...
 

Friends

bool operator== (const OUString &rStr1, const OUString &rStr2)
 
bool operator== (const OUString &rStr1, const sal_Unicode *pStr2)
 
bool operator== (const sal_Unicode *pStr1, const OUString &rStr2)
 
bool operator!= (const OUString &rStr1, const OUString &rStr2)
 
bool operator!= (const OUString &rStr1, const sal_Unicode *pStr2)
 
bool operator!= (const sal_Unicode *pStr1, const OUString &rStr2)
 
bool operator< (const OUString &rStr1, const OUString &rStr2)
 
bool operator> (const OUString &rStr1, const OUString &rStr2)
 
bool operator<= (const OUString &rStr1, const OUString &rStr2)
 
bool operator>= (const OUString &rStr1, const OUString &rStr2)
 
template<typename T >
libreoffice_internal::ConstCharArrayDetector
< T, bool >::Type 
operator== (const OUString &rString, T &literal)
 Compare string to an ASCII string literal. More...
 
template<typename T >
libreoffice_internal::ConstCharArrayDetector
< T, bool >::Type 
operator== (T &literal, const OUString &rString)
 Compare string to an ASCII string literal. More...
 
template<typename T >
libreoffice_internal::ConstCharArrayDetector
< T, bool >::Type 
operator!= (const OUString &rString, T &literal)
 Compare string to an ASCII string literal. More...
 
template<typename T >
libreoffice_internal::ConstCharArrayDetector
< T, bool >::Type 
operator!= (T &literal, const OUString &rString)
 Compare string to an ASCII string literal. More...
 
OUString operator+ (const OUString &rStr1, const OUString &rStr2)
 

Detailed Description

This String class provides base functionality for C++ like Unicode character array handling.

The advantage of this class is that it handles all the memory management for you - and it does it more efficiently. If you assign a string to another string, the data of both strings are shared (without any copy operation or memory allocation) as long as you do not change the string. This class also stores the length of the string, so that many operations are faster than the C-str-functions.

This class provides only readonly string handling. So you could create a string and you could only query the content from this string. It provides also functionality to change the string, but this results in every case in a new string instance (in the most cases with a memory allocation). You don't have functionality to change the content of the string. If you want to change the string content, then you should use the OStringBuffer class, which provides these functionalities and avoids too much memory allocation.

The design of this class is similar to the string classes in Java so less people should have understanding problems when they use this class.

Constructor & Destructor Documentation

rtl::OUString::OUString ( )
inline

New string containing no characters.

rtl::OUString::OUString ( const OUString str)
inline

New string from OUString.

Parameters
stra OUString.
rtl::OUString::OUString ( rtl_uString *  str)
inline

New string from OUString data.

Parameters
stra OUString data.
rtl::OUString::OUString ( rtl_uString *  str,
__sal_NoAcquire   
)
inline

New OUString from OUString data without acquiring it.

Takeover of ownership.

The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this from other constructors.

Parameters
strOUString data
rtl::OUString::OUString ( sal_Unicode  value)
inlineexplicit

New string from a single Unicode character.

Parameters
valuea Unicode character.
rtl::OUString::OUString ( const sal_Unicode value)
inline

New string from a Unicode character buffer array.

Parameters
valuea NULL-terminated Unicode character array.
rtl::OUString::OUString ( const sal_Unicode value,
sal_Int32  length 
)
inline

New string from a Unicode character buffer array.

Parameters
valuea Unicode character array.
lengththe number of character which should be copied. The character array length must be greater than or equal to this value.
template<typename T >
rtl::OUString::OUString ( T &  literal,
typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type  = libreoffice_internal::Dummy() 
)
inline

New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set (i.e.

first 128 characters). This constructor allows an efficient and convenient way to create OUString instances from ASCII literals. When creating strings from data that is not pure ASCII, it needs to be converted to OUString by explicitly providing the encoding to use for the conversion.

If there are any embedded \0's in the string literal, the result is undefined. Use the overload that explicitly accepts length.

Parameters
literalthe 8-bit ASCII string literal
Since
LibreOffice 3.6
rtl::OUString::OUString ( const sal_Char value,
sal_Int32  length,
rtl_TextEncoding  encoding,
sal_uInt32  convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS 
)
inline

New string from an 8-Bit character buffer array.

Parameters
valueAn 8-Bit character array.
lengthThe number of character which should be converted. The 8-Bit character array length must be greater than or equal to this value.
encodingThe text encoding from which the 8-Bit character sequence should be converted.
convertFlagsFlags which control the conversion. see RTL_TEXTTOUNICODE_FLAGS_...
Exceptions
std::bad_allocis thrown if an out-of-memory condition occurs
rtl::OUString::OUString ( sal_uInt32 const *  codePoints,
sal_Int32  codePointCount 
)
inlineexplicit

Create a new string from an array of Unicode code points.

Parameters
codePointsan array of at least codePointCount code points, which each must be in the range from 0 to 0x10FFFF, inclusive. May be null if codePointCount is zero.
codePointCountthe non-negative number of code points.
Exceptions
std::bad_allocis thrown if either an out-of-memory condition occurs or the resulting number of UTF-16 code units would have been larger than SAL_MAX_INT32.
Since
UDK 3.2.7
rtl::OUString::~OUString ( )
inline

Release the string data.

Member Function Documentation

static OUString rtl::OUString::boolean ( bool  b)
inlinestatic

Returns the string representation of the boolean argument.

If the argument is true, the string "true" is returned. If the argument is false, the string "false" is returned. This function can't be used for language specific conversion.

Parameters
ba bool.
Returns
a string with the string representation of the argument.
Since
LibreOffice 4.1
void rtl::OUString::clear ( )
inline

Clears the string, i.e, makes a zero-character string.

Since
LibreOffice 4.4
sal_Int32 rtl::OUString::compareTo ( const OUString str) const
inline

Compares two strings.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. This function can't be used for language specific sorting.

Parameters
strthe object to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
sal_Int32 rtl::OUString::compareTo ( const OUString str,
sal_Int32  maxLength 
) const
inline

Compares two strings with a maximum count of characters.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. This function can't be used for language specific sorting.

Parameters
strthe object to be compared.
maxLengththe maximum count of characters to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
Since
UDK 3.2.7
sal_Int32 rtl::OUString::compareToAscii ( const sal_Char asciiStr) const
inline

Compares two strings.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated. This function can't be used for language specific sorting.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
sal_Int32 rtl::OUString::compareToAscii ( const sal_Char asciiStr,
sal_Int32  maxLength 
) const
inline

Compares two strings with a maximum count of characters.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated. This function can't be used for language specific sorting.
Deprecated:
This is a confusing overload with unexpectedly different semantics from the one-parameter form, so it is marked as deprecated. Practically all uses compare the return value against zero and can thus be replaced with uses of startsWith.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
maxLengththe maximum count of characters to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
sal_Int32 rtl::OUString::compareToIgnoreAsciiCase ( const OUString str) const
inline

Perform a ASCII lowercase comparison of two strings.

Compare the two strings with uppercase ASCII character values between 65 and 90 (ASCII A-Z) interpreted as values between 97 and 122 (ASCII a-z). This function can't be used for language specific comparison.

Parameters
strthe object to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
Since
LibreOffice 4.0
sal_Int32 rtl::OUString::compareToIgnoreAsciiCaseAscii ( const sal_Char asciiStr) const
inline

Compares two ASCII strings ignoring case.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated. This function can't be used for language specific sorting.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
Since
LibreOffice 3.5
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::concat ( const OUString str) const
inline

Concatenates the specified string to the end of this string.

Parameters
strthe string that is concatenated to the end of this string.
Returns
a string that represents the concatenation of this string followed by the string argument.
bool rtl::OUString::convertToString ( OString pTarget,
rtl_TextEncoding  nEncoding,
sal_uInt32  nFlags 
) const
inline

Converts to an OString, signalling failure.

Parameters
pTargetAn out parameter receiving the converted OString. Must not be null; the contents are not modified if conversion fails (convertToOString returns false).
nEncodingThe text encoding to convert into. Must be an octet encoding (i.e., rtl_isOctetTextEncoding(nEncoding) must return true).
nFlagsA combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the conversion (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH need not be included, it is implicitly assumed. Typical uses are either RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS (make a best efforts conversion).
Returns
True if the conversion succeeded, false otherwise.
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::copy ( sal_Int32  beginIndex) const
inline

Returns a new string that is a substring of this string.

The substring begins at the specified beginIndex. If beginIndex is negative or be greater than the length of this string, behaviour is undefined.

Parameters
beginIndexthe beginning index, inclusive.
Returns
the specified substring.
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::copy ( sal_Int32  beginIndex,
sal_Int32  count 
) const
inline

Returns a new string that is a substring of this string.

The substring begins at the specified beginIndex and contains count characters. If either beginIndex or count are negative, or beginIndex + count are greater than the length of this string then behaviour is undefined.

Parameters
beginIndexthe beginning index, inclusive.
countthe number of characters.
Returns
the specified substring.
static OUString rtl::OUString::createFromAscii ( const sal_Char value)
inlinestatic

Returns a OUString copied without conversion from an ASCII character string.

Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated.

Note that for string literals it is simpler and more efficient to directly use the OUString constructor.

Parameters
valuethe 8-Bit ASCII character string
Returns
a string with the string representation of the argument.
bool rtl::OUString::endsWith ( OUString const &  str,
OUString rest = NULL 
) const
inline

Check whether this string ends with a given substring.

Parameters
strthe substring to be compared
restif non-null, and this function returns true, then assign a copy of the remainder of this string to *rest. Available since LibreOffice 4.2
Returns
true if and only if the given str appears as a substring at the end of this string
Since
LibreOffice 3.6
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::endsWith ( T &  literal,
OUString rest = NULL 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
bool rtl::OUString::endsWithAsciiL ( char const *  asciiStr,
sal_Int32  asciiStrLength 
) const
inline

Check whether this string ends with a given ASCII string.

Parameters
asciiStra sequence of at least asciiStrLength ASCII characters (bytes in the range 0x00–0x7F)
asciiStrLengththe length of asciiStr; must be non-negative
Returns
true if this string ends with asciiStr; otherwise, false is returned
Since
UDK 3.2.7
bool rtl::OUString::endsWithIgnoreAsciiCase ( OUString const &  str,
OUString rest = NULL 
) const
inline

Check whether this string ends with a given string, ignoring the case of ASCII letters.

Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). This function can't be used for language specific comparison.

Parameters
strthe substring to be compared
restif non-null, and this function returns true, then assign a copy of the remainder of this string to *rest. Available since LibreOffice 4.2
Returns
true if and only if the given str appears as a substring at the end of this string, ignoring the case of ASCII letters ("A"–"Z" and "a"–"z")
Since
LibreOffice 3.6
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::endsWithIgnoreAsciiCase ( T &  literal,
OUString rest = NULL 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
bool rtl::OUString::endsWithIgnoreAsciiCaseAsciiL ( char const *  asciiStr,
sal_Int32  asciiStrLength 
) const
inline

Check whether this string ends with a given ASCII string, ignoring the case of ASCII letters.

Parameters
asciiStra sequence of at least asciiStrLength ASCII characters (bytes in the range 0x00–0x7F)
asciiStrLengththe length of asciiStr; must be non-negative
Returns
true if this string ends with asciiStr, ignoring the case of ASCII letters ("A"–"Z" and "a"–"z"); otherwise, false is returned
bool rtl::OUString::equals ( const OUString str) const
inline

Perform a comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string. This function can't be used for language specific comparison.

Parameters
strthe object to be compared.
Returns
true if the strings are equal; false, otherwise.
bool rtl::OUString::equalsAscii ( const sal_Char asciiStr) const
inline

Perform a comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated. This function can't be used for language specific comparison.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
Returns
true if the strings are equal; false, otherwise.
bool rtl::OUString::equalsAsciiL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength 
) const
inline

Perform a comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated and must be greater than or equal to asciiStrLength. This function can't be used for language specific comparison.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
asciiStrLengththe length of the ascii string
Returns
true if the strings are equal; false, otherwise.
bool rtl::OUString::equalsIgnoreAsciiCase ( const OUString str) const
inline

Perform a ASCII lowercase comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string, ignoring the case. Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). This function can't be used for language specific comparison.

Parameters
strthe object to be compared.
Returns
true if the strings are equal; false, otherwise.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::equalsIgnoreAsciiCase ( T &  literal) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
bool rtl::OUString::equalsIgnoreAsciiCaseAscii ( const sal_Char asciiStr) const
inline

Perform a ASCII lowercase comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string, ignoring the case. Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated. This function can't be used for language specific comparison.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
Returns
true if the strings are equal; false, otherwise.
bool rtl::OUString::equalsIgnoreAsciiCaseAsciiL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength 
) const
inline

Perform an ASCII lowercase comparison of two strings.

The result is true if and only if second string represents the same sequence of characters as the first string, ignoring the case. Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and 127. The ASCII string must be NULL-terminated and must be greater than or equal to asciiStrLength. This function can't be used for language specific comparison.

Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
asciiStrLengththe length of the ascii string
Returns
true if the strings are equal; false, otherwise.
static OUString rtl::OUString::fromUtf8 ( const OString rSource)
inlinestatic

Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.

Parameters
rSourcean OString to convert
Since
LibreOffice 4.4
sal_Int32 rtl::OUString::getLength ( ) const
inline

Returns the length of this string.

The length is equal to the number of Unicode characters in this string.

Returns
the length of the sequence of characters represented by this object.
const sal_Unicode* rtl::OUString::getStr ( ) const
inline

Returns a pointer to the Unicode character buffer for this string.

It isn't necessarily NULL terminated.

Returns
a pointer to the Unicode characters buffer for this object.
OUString rtl::OUString::getToken ( sal_Int32  token,
sal_Unicode  cTok,
sal_Int32 &  index 
) const
inline

Returns a token in the string.

Example: sal_Int32 nIndex = 0; do { ... OUString aToken = aStr.getToken( 0, ';', nIndex ); ... } while ( nIndex >= 0 );

Parameters
tokenthe number of the token to return
cTokthe character which separate the tokens.
indexthe position at which the token is searched in the string. The index must not be greater than the length of the string. This param is set to the position of the next token or to -1, if it is the last token.
Returns
the token; if either token or index is negative, an empty token is returned (and index is set to -1)
OUString rtl::OUString::getToken ( sal_Int32  count,
sal_Unicode  separator 
) const
inline

Returns a token from the string.

The same as getToken(sal_Int32, sal_Unicode, sal_Int32 &), but always passing in 0 as the start index in the third argument.

Parameters
countthe number of the token to return, starting with 0
separatorthe character which separates the tokens
Returns
the given token, or an empty string
Since
LibreOffice 3.6
sal_Int32 rtl::OUString::hashCode ( ) const
inline

Returns a hashcode for this string.

Returns
a hash code value for this object.
See Also
rtl::OUStringHash for convenient use of std::unordered_map
sal_Int32 rtl::OUString::indexOf ( sal_Unicode  ch,
sal_Int32  fromIndex = 0 
) const
inline

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

Parameters
chcharacter to be located.
fromIndexthe index to start the search from. The index must be greater than or equal to 0 and less than or equal to the string length.
Returns
the index of the first occurrence of the character in the character sequence represented by this string that is greater than or equal to fromIndex, or -1 if the character does not occur.
sal_Int32 rtl::OUString::indexOf ( const OUString str,
sal_Int32  fromIndex = 0 
) const
inline

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Parameters
strthe substring to search for.
fromIndexthe index to start the search from.
Returns
If the string argument occurs one or more times as a substring within this string at the starting index, then the index of the first character of the first such substring is returned. If it does not occur as a substring starting at fromIndex or beyond, -1 is returned.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OUString::indexOf ( T &  literal,
sal_Int32  fromIndex = 0 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
sal_Int32 rtl::OUString::indexOfAsciiL ( char const *  str,
sal_Int32  len,
sal_Int32  fromIndex = 0 
) const
inline

Returns the index within this string of the first occurrence of the specified ASCII substring, starting at the specified index.

Parameters
strthe substring to be searched for. Need not be null-terminated, but must be at least as long as the specified len. Must only contain characters in the ASCII range 0x00–7F.
lenthe length of the substring; must be non-negative.
fromIndexthe index to start the search from. Must be in the range from zero to the length of this string, inclusive.
Returns
the index (starting at 0) of the first character of the first occurrence of the substring within this string starting at the given fromIndex, or -1 if the substring does not occur. If len is zero, -1 is returned.
Since
UDK 3.2.7
OUString rtl::OUString::intern ( ) const
inline

Return a canonical representation for a string.

A pool of strings, initially empty is maintained privately by the string class. On invocation, if present in the pool the original string will be returned. Otherwise this string, or a copy thereof will be added to the pool and returned.

Returns
a version of the string from the pool.
Exceptions
std::bad_allocis thrown if an out-of-memory condition occurs
Since
UDK 3.2.7
static OUString rtl::OUString::intern ( const sal_Char value,
sal_Int32  length,
rtl_TextEncoding  encoding,
sal_uInt32  convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
sal_uInt32 *  pInfo = NULL 
)
inlinestatic

Return a canonical representation for a converted string.

A pool of strings, initially empty is maintained privately by the string class. On invocation, if present in the pool the original string will be returned. Otherwise this string, or a copy thereof will be added to the pool and returned.

Parameters
valuea 8-Bit character array.
lengththe number of character which should be converted. The 8-Bit character array length must be greater than or equal to this value.
encodingthe text encoding from which the 8-Bit character sequence should be converted.
convertFlagsflags which controls the conversion. see RTL_TEXTTOUNICODE_FLAGS_...
pInfopointer to return conversion status or NULL.
Returns
a version of the converted string from the pool.
Exceptions
std::bad_allocis thrown if an out-of-memory condition occurs
Since
UDK 3.2.7
bool rtl::OUString::isEmpty ( ) const
inline

Checks if a string is empty.

Returns
true if the string is empty; false, otherwise.
Since
LibreOffice 3.4
sal_uInt32 rtl::OUString::iterateCodePoints ( sal_Int32 *  indexUtf16,
sal_Int32  incrementCodePoints = 1 
) const
inline

Iterate through this string based on code points instead of UTF-16 code units.

See Chapter 3 of The Unicode Standard 5.0 (Addison–Wesley, 2006) for definitions of the various terms used in this description.

This string is interpreted as a sequence of zero or more UTF-16 code units. For each index into this sequence (from zero to one less than the length of the sequence, inclusive), a code point represented starting at the given index is computed as follows:

  • If the UTF-16 code unit addressed by the index constitutes a well-formed UTF-16 code unit sequence, the computed code point is the scalar value encoded by that UTF-16 code unit sequence.
  • Otherwise, if the index is at least two UTF-16 code units away from the end of the sequence, and the sequence of two UTF-16 code units addressed by the index constitutes a well-formed UTF-16 code unit sequence, the computed code point is the scalar value encoded by that UTF-16 code unit sequence.
  • Otherwise, the computed code point is the UTF-16 code unit addressed by the index. (This last case catches unmatched surrogates as well as indices pointing into the middle of surrogate pairs.)
Parameters
indexUtf16pointer to a UTF-16 based index into this string; must not be null. On entry, the index must be in the range from zero to the length of this string (in UTF-16 code units), inclusive. Upon successful return, the index will be updated to address the UTF-16 code unit that is the given incrementCodePoints away from the initial index.
incrementCodePointsthe number of code points to move the given *indexUtf16. If non-negative, moving is done after determining the code point at the index. If negative, moving is done before determining the code point at the (then updated) index. The value must be such that the resulting UTF-16 based index is in the range from zero to the length of this string (in UTF-16 code units), inclusive.
Returns
the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that is represented within this string starting at the index computed as follows: If incrementCodePoints is non-negative, the index is the initial value of *indexUtf16; if incrementCodePoints is negative, the index is the updated value of *indexUtf16. In either case, the computed index must be in the range from zero to one less than the length of this string (in UTF-16 code units), inclusive.
Since
UDK 3.2.7
sal_Int32 rtl::OUString::lastIndexOf ( sal_Unicode  ch) const
inline

Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.

Parameters
chcharacter to be located.
Returns
the index of the last occurrence of the character in the character sequence represented by this string, or -1 if the character does not occur.
sal_Int32 rtl::OUString::lastIndexOf ( sal_Unicode  ch,
sal_Int32  fromIndex 
) const
inline

Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.

Parameters
chcharacter to be located.
fromIndexthe index before which to start the search.
Returns
the index of the last occurrence of the character in the character sequence represented by this string that is less than fromIndex, or -1 if the character does not occur before that point.
sal_Int32 rtl::OUString::lastIndexOf ( const OUString str) const
inline

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.

The returned index indicates the starting index of the substring in this string. If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Parameters
strthe substring to search for.
Returns
If the string argument occurs one or more times as a substring within this string, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.
sal_Int32 rtl::OUString::lastIndexOf ( const OUString str,
sal_Int32  fromIndex 
) const
inline

Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.

The returned index indicates the starting index of the substring in this string. If str doesn't include any character, always -1 is returned. This is also the case, if both strings are empty.

Parameters
strthe substring to search for.
fromIndexthe index before which to start the search.
Returns
If the string argument occurs one or more times as a substring within this string before the starting index, then the index of the first character of the last such substring is returned. Otherwise, -1 is returned.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OUString::lastIndexOf ( T &  literal) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
sal_Int32 rtl::OUString::lastIndexOfAsciiL ( char const *  str,
sal_Int32  len 
) const
inline

Returns the index within this string of the last occurrence of the specified ASCII substring.

Parameters
strthe substring to be searched for. Need not be null-terminated, but must be at least as long as the specified len. Must only contain characters in the ASCII range 0x00–7F.
lenthe length of the substring; must be non-negative.
Returns
the index (starting at 0) of the first character of the last occurrence of the substring within this string, or -1 if the substring does not occur. If len is zero, -1 is returned.
Since
UDK 3.2.7
bool rtl::OUString::match ( const OUString str,
sal_Int32  fromIndex = 0 
) const
inline

Match against a substring appearing in this string.

The result is true if and only if the second string appears as a substring of this string, at the given position. This function can't be used for language specific comparison.

Parameters
strthe object (substring) to be compared.
fromIndexthe index to start the comparion from. The index must be greater than or equal to 0 and less or equal as the string length.
Returns
true if str match with the characters in the string at the given position; false, otherwise.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::match ( T &  literal,
sal_Int32  fromIndex = 0 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
bool rtl::OUString::matchAsciiL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength,
sal_Int32  fromIndex = 0 
) const
inline

Match against a substring appearing in this string.

The result is true if and only if the second string appears as a substring of this string, at the given position. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated and must be greater than or equal to asciiStrLength. This function can't be used for language specific comparison.
Parameters
asciiStrthe object (substring) to be compared.
asciiStrLengththe length of asciiStr.
fromIndexthe index to start the comparion from. The index must be greater than or equal to 0 and less than or equal to the string length.
Returns
true if str match with the characters in the string at the given position; false, otherwise.
bool rtl::OUString::matchIgnoreAsciiCase ( const OUString str,
sal_Int32  fromIndex = 0 
) const
inline

Match against a substring appearing in this string, ignoring the case of ASCII letters.

The result is true if and only if the second string appears as a substring of this string, at the given position. Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). This function can't be used for language specific comparison.

Parameters
strthe object (substring) to be compared.
fromIndexthe index to start the comparion from. The index must be greater than or equal to 0 and less than or equal to the string length.
Returns
true if str match with the characters in the string at the given position; false, otherwise.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::matchIgnoreAsciiCase ( T &  literal,
sal_Int32  fromIndex = 0 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 3.6
bool rtl::OUString::matchIgnoreAsciiCaseAsciiL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength,
sal_Int32  fromIndex = 0 
) const
inline

Match against a substring appearing in this string, ignoring the case of ASCII letters.

The result is true if and only if the second string appears as a substring of this string, at the given position. Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and

  1. The ASCII string must be NULL-terminated and must be greater than or equal to asciiStrLength. This function can't be used for language specific comparison.
Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
asciiStrLengththe length of the ascii string
fromIndexthe index to start the comparion from. The index must be greater than or equal to 0 and less than or equal to the string length.
Returns
true if str match with the characters in the string at the given position; false, otherwise.
static OUString rtl::OUString::number ( int  i,
sal_Int16  radix = 10 
)
inlinestatic

Returns the string representation of the integer argument.

This function can't be used for language specific conversion.

Parameters
ian integer value
radixthe radix (between 2 and 36)
Returns
a string with the string representation of the argument.
Since
LibreOffice 4.1
static OUString rtl::OUString::number ( unsigned int  i,
sal_Int16  radix = 10 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
LibreOffice 4.1
static OUString rtl::OUString::number ( long  i,
sal_Int16  radix = 10 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
LibreOffice 4.1
static OUString rtl::OUString::number ( unsigned long  i,
sal_Int16  radix = 10 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
LibreOffice 4.1
static OUString rtl::OUString::number ( long long  ll,
sal_Int16  radix = 10 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
LibreOffice 4.1
static OUString rtl::OUString::number ( unsigned long long  ll,
sal_Int16  radix = 10 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
LibreOffice 4.1
static OUString rtl::OUString::number ( float  f)
inlinestatic

Returns the string representation of the float argument.

This function can't be used for language specific conversion.

Parameters
fa float.
Returns
a string with the string representation of the argument.
Since
LibreOffice 4.1
static OUString rtl::OUString::number ( double  d)
inlinestatic

Returns the string representation of the double argument.

This function can't be used for language specific conversion.

Parameters
da double.
Returns
a string with the string representation of the argument.
Since
LibreOffice 4.1
OUString& rtl::OUString::operator+= ( const OUString str)
inline

Append a string to this string.

Parameters
stra OUString.
template<typename T >
libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type rtl::OUString::operator+= ( T &  literal)
inline

Append an ASCII string literal to this string.

Parameters
literalan 8-bit ASCII-only string literal
Since
LibreOffice 5.1
OUString& rtl::OUString::operator= ( const OUString str)
inline

Assign a new string.

Parameters
stra OUString.
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, OUString& >::Type rtl::OUString::operator= ( T &  literal)
inline

Assign a new string from an 8-Bit string literal that is expected to contain only characters in the ASCII set (i.e.

first 128 characters). This operator allows an efficient and convenient way to assign OUString instances from ASCII literals. When assigning strings from data that is not pure ASCII, it needs to be converted to OUString by explicitly providing the encoding to use for the conversion.

Parameters
literalthe 8-bit ASCII string literal
Since
LibreOffice 3.6
sal_Unicode rtl::OUString::operator[] ( sal_Int32  index) const
inline

Access to individual characters.

Parameters
indexmust be non-negative and less than length.
Returns
the character at the given index.
Since
LibreOffice 3.5
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::replace ( sal_Unicode  oldChar,
sal_Unicode  newChar 
) const
inline

Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.

If the character oldChar does not occur in the character sequence represented by this object, then the string is assigned with str.

Parameters
oldCharthe old character.
newCharthe new character.
Returns
a string derived from this string by replacing every occurrence of oldChar with newChar.
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::replaceAll ( OUString const &  from,
OUString const &  to,
sal_Int32  fromIndex = 0 
) const
inline

Returns a new string resulting from replacing all occurrences of a given substring with another substring.

Replacing subsequent occurrences picks up only after a given replacement. That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".

Parameters
fromthe substring to be replaced
tothe replacing substring
fromIndexthe position in the string where we will begin searching
Since
LibreOffice 4.0
template<typename T >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type rtl::OUString::replaceAll ( T &  from,
OUString const &  to 
) const
inline

Returns a new string resulting from replacing all occurrences of a given substring with another substring.

Replacing subsequent occurrences picks up only after a given replacement. That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".

Parameters
fromASCII string literal, the substring to be replaced
tothe replacing substring
Since
LibreOffice 3.6
template<typename T >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type rtl::OUString::replaceAll ( OUString const &  from,
T &  to 
) const
inline

Returns a new string resulting from replacing all occurrences of a given substring with another substring.

Replacing subsequent occurrences picks up only after a given replacement. That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".

Parameters
fromthe substring to be replaced
toASCII string literal, the replacing substring
Since
LibreOffice 5.1
template<typename T1 , typename T2 >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type rtl::OUString::replaceAll ( T1 &  from,
T2 &  to 
) const
inline

Returns a new string resulting from replacing all occurrences of a given substring with another substring.

Replacing subsequent occurrences picks up only after a given replacement. That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".

Parameters
fromASCII string literal, the substring to be replaced
toASCII string literal, the substring to be replaced
Since
LibreOffice 3.6
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::replaceAt ( sal_Int32  index,
sal_Int32  count,
const OUString newStr 
) const
inline

Returns a new string resulting from replacing n = count characters from position index in this string with newStr.

Parameters
indexthe replacing index in str. The index must be greater than or equal to 0 and less than or equal to the length of the string.
countthe count of characters that will be replaced The count must be greater than or equal to 0 and less than or equal to the length of the string minus index.
newStrthe new substring.
Returns
the new string.
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::replaceFirst ( OUString const &  from,
OUString const &  to,
sal_Int32 *  index = NULL 
) const
inline

Returns a new string resulting from replacing the first occurrence of a given substring with another substring.

Parameters
fromthe substring to be replaced
tothe replacing substring
[in,out]indexpointer to a start index; if the pointer is non-null: upon entry to the function, its value is the index into this string at which to start searching for the from substring, the value must be non-negative and not greater than this string's length; upon exiting the function its value is the index into this string at which the replacement took place or -1 if no replacement took place; if the pointer is null, searching always starts at index 0
Since
LibreOffice 3.6
template<typename T >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type rtl::OUString::replaceFirst ( T &  from,
OUString const &  to,
sal_Int32 *  index = NULL 
) const
inline

Returns a new string resulting from replacing the first occurrence of a given substring with another substring.

Parameters
fromASCII string literal, the substring to be replaced
tothe replacing substring
[in,out]indexpointer to a start index; if the pointer is non-null: upon entry to the function, its value is the index into the this string at which to start searching for the from substring, the value must be non-negative and not greater than this string's length; upon exiting the function its value is the index into this string at which the replacement took place or -1 if no replacement took place; if the pointer is null, searching always starts at index 0
Since
LibreOffice 3.6
template<typename T >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type rtl::OUString::replaceFirst ( OUString const &  from,
T &  to,
sal_Int32 *  index = NULL 
) const
inline

Returns a new string resulting from replacing the first occurrence of a given substring with another substring.

Parameters
fromthe substring to be replaced
toASCII string literal, the replacing substring
[in,out]indexpointer to a start index; if the pointer is non-null: upon entry to the function, its value is the index into the this string at which to start searching for the from substring, the value must be non-negative and not greater than this string's length; upon exiting the function its value is the index into this string at which the replacement took place or -1 if no replacement took place; if the pointer is null, searching always starts at index 0
Since
LibreOffice 5.1
template<typename T1 , typename T2 >
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type rtl::OUString::replaceFirst ( T1 &  from,
T2 &  to,
sal_Int32 *  index = NULL 
) const
inline

Returns a new string resulting from replacing the first occurrence of a given substring with another substring.

Parameters
fromASCII string literal, the substring to be replaced
toASCII string literal, the substring to be replaced
[in,out]indexpointer to a start index; if the pointer is non-null: upon entry to the function, its value is the index into the this string at which to start searching for the from substring, the value must be non-negative and not greater than this string's length; upon exiting the function its value is the index into this string at which the replacement took place or -1 if no replacement took place; if the pointer is null, searching always starts at index 0
Since
LibreOffice 3.6
sal_Int32 rtl::OUString::reverseCompareTo ( const OUString str) const
inline

Compares two strings in reverse order.

The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. This function can't be used for language specific sorting.

Parameters
strthe object to be compared.
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OUString::reverseCompareTo ( T &  literal) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 4.1
sal_Int32 rtl::OUString::reverseCompareToAsciiL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength 
) const
inline

Compares two strings in reverse order.

This could be useful, if normally both strings start with the same content. The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and 127. The ASCII string must be NULL-terminated and must be greater than or equal to asciiStrLength. This function can't be used for language specific sorting.

Parameters
asciiStrthe 8-Bit ASCII character string to be compared.
asciiStrLengththe length of the ascii string
Returns
0 - if both strings are equal < 0 - if this string is less than the string argument > 0 - if this string is greater than the string argument
bool rtl::OUString::startsWith ( OUString const &  str,
OUString rest = NULL 
) const
inline

Check whether this string starts with a given substring.

Parameters
strthe substring to be compared
restif non-null, and this function returns true, then assign a copy of the remainder of this string to *rest. Available since LibreOffice 4.2
Returns
true if and only if the given str appears as a substring at the start of this string
Since
LibreOffice 4.0
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::startsWith ( T &  literal,
OUString rest = NULL 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 4.0
bool rtl::OUString::startsWithIgnoreAsciiCase ( OUString const &  str,
OUString rest = NULL 
) const
inline

Check whether this string starts with a given string, ignoring the case of ASCII letters.

Character values between 65 and 90 (ASCII A-Z) are interpreted as values between 97 and 122 (ASCII a-z). This function can't be used for language specific comparison.

Parameters
strthe substring to be compared
restif non-null, and this function returns true, then assign a copy of the remainder of this string to *rest. Available since LibreOffice 4.2
Returns
true if and only if the given str appears as a substring at the start of this string, ignoring the case of ASCII letters ("A"–"Z" and "a"–"z")
Since
LibreOffice 4.0
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type rtl::OUString::startsWithIgnoreAsciiCase ( T &  literal,
OUString rest = NULL 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function accepts an ASCII string literal as its argument.

Since
LibreOffice 4.0
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::toAsciiLowerCase ( ) const
inline

Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-122).

This function can't be used for language specific conversion. If the string doesn't contain characters which must be converted, then the new string is assigned with str.

Returns
the string, converted to ASCII lowercase.
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::toAsciiUpperCase ( ) const
inline

Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-90).

This function can't be used for language specific conversion. If the string doesn't contain characters which must be converted, then the new string is assigned with str.

Returns
the string, converted to ASCII uppercase.
bool rtl::OUString::toBoolean ( ) const
inline

Returns the Boolean value from this string.

This function can't be used for language specific conversion.

Returns
true, if the string is 1 or "True" in any ASCII case. false in any other case.
sal_Unicode rtl::OUString::toChar ( ) const
inline

Returns the first character from this string.

Returns
the first character from this string or 0, if this string is empty.
double rtl::OUString::toDouble ( ) const
inline

Returns the double value from this string.

This function can't be used for language specific conversion.

Returns
the double represented from this string. 0.0 if this string represents no number.
float rtl::OUString::toFloat ( ) const
inline

Returns the float value from this string.

This function can't be used for language specific conversion.

Returns
the float represented from this string. 0.0 if this string represents no number.
sal_Int32 rtl::OUString::toInt32 ( sal_Int16  radix = 10) const
inline

Returns the int32 value from this string.

This function can't be used for language specific conversion.

Parameters
radixthe radix (between 2 and 36)
Returns
the int32 represented from this string. 0 if this string represents no number or one of too large magnitude.
sal_Int64 rtl::OUString::toInt64 ( sal_Int16  radix = 10) const
inline

Returns the int64 value from this string.

This function can't be used for language specific conversion.

Parameters
radixthe radix (between 2 and 36)
Returns
the int64 represented from this string. 0 if this string represents no number or one of too large magnitude.
sal_uInt32 rtl::OUString::toUInt32 ( sal_Int16  radix = 10) const
inline

Returns the uint32 value from this string.

This function can't be used for language specific conversion.

Parameters
radixthe radix (between 2 and 36)
Returns
the uint32 represented from this string. 0 if this string represents no number or one of too large magnitude.
Since
LibreOffice 4.2
sal_uInt64 rtl::OUString::toUInt64 ( sal_Int16  radix = 10) const
inline

Returns the uint64 value from this string.

This function can't be used for language specific conversion.

Parameters
radixthe radix (between 2 and 36)
Returns
the uint64 represented from this string. 0 if this string represents no number or one of too large magnitude.
Since
LibreOffice 4.1
OString rtl::OUString::toUtf8 ( ) const
inline

Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.

In other words, you must not use this method on a random sequence of UTF-16 code units, but only at places where it is assumed that the content is a proper string.

Since
LibreOffice 4.4
SAL_WARN_UNUSED_RESULT OUString rtl::OUString::trim ( ) const
inline

Returns a new string resulting from removing white space from both ends of the string.

All characters that have codes less than or equal to 32 (the space character) are considered to be white space. If the string doesn't contain white spaces at both ends, then the new string is assigned with str.

Returns
the string, with white space removed from the front and end.
static OUString const& rtl::OUString::unacquired ( rtl_uString *const *  ppHandle)
inlinestatic

Provides an OUString const & passing a storage pointer of an rtl_uString * handle.

It is more convenient to use C++ OUString member functions when dealing with rtl_uString * handles. Using this function avoids unnecessary acquire()/release() calls for a temporary OUString object.

Parameters
ppHandlepointer to storage
Returns
OUString const & based on given storage
static OUString rtl::OUString::valueOf ( sal_Bool  b)
inlinestatic

Returns the string representation of the sal_Bool argument.

If the sal_Bool is true, the string "true" is returned. If the sal_Bool is false, the string "false" is returned. This function can't be used for language specific conversion.

Parameters
ba sal_Bool.
Returns
a string with the string representation of the argument.
Deprecated:
use boolean()
static OUString rtl::OUString::valueOf ( sal_Unicode  c)
inlinestatic

Returns the string representation of the char argument.

Parameters
ca character.
Returns
a string with the string representation of the argument.
Deprecated:
use operator, function or constructor taking char or sal_Unicode argument
static OUString rtl::OUString::valueOf ( sal_Int32  i,
sal_Int16  radix = 10 
)
inlinestatic

Returns the string representation of the int argument.

This function can't be used for language specific conversion.

Parameters
ia int32.
radixthe radix (between 2 and 36)
Returns
a string with the string representation of the argument.
Deprecated:
use number()
static OUString rtl::OUString::valueOf ( sal_Int64  ll,
sal_Int16  radix = 10 
)
inlinestatic

Returns the string representation of the long argument.

This function can't be used for language specific conversion.

Parameters
lla int64.
radixthe radix (between 2 and 36)
Returns
a string with the string representation of the argument.
Deprecated:
use number()
static OUString rtl::OUString::valueOf ( float  f)
inlinestatic

Returns the string representation of the float argument.

This function can't be used for language specific conversion.

Parameters
fa float.
Returns
a string with the string representation of the argument.
Deprecated:
use number()
static OUString rtl::OUString::valueOf ( double  d)
inlinestatic

Returns the string representation of the double argument.

This function can't be used for language specific conversion.

Parameters
da double.
Returns
a string with the string representation of the argument.
Deprecated:
use number()

Friends And Related Function Documentation

bool operator!= ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator!= ( const OUString rStr1,
const sal_Unicode pStr2 
)
friend
bool operator!= ( const sal_Unicode pStr1,
const OUString rStr2 
)
friend
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!= ( const OUString rString,
T &  literal 
)
friend

Compare string to an ASCII string literal.

This operator is equal to calling !equalsAsciiL().

Since
LibreOffice 3.6
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!= ( T &  literal,
const OUString rString 
)
friend

Compare string to an ASCII string literal.

This operator is equal to calling !equalsAsciiL().

Since
LibreOffice 3.6
OUString operator+ ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator< ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator<= ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator== ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator== ( const OUString rStr1,
const sal_Unicode pStr2 
)
friend
bool operator== ( const sal_Unicode pStr1,
const OUString rStr2 
)
friend
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator== ( const OUString rString,
T &  literal 
)
friend

Compare string to an ASCII string literal.

This operator is equal to calling equalsAsciiL().

Since
LibreOffice 3.6
template<typename T >
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator== ( T &  literal,
const OUString rString 
)
friend

Compare string to an ASCII string literal.

This operator is equal to calling equalsAsciiL().

Since
LibreOffice 3.6
bool operator> ( const OUString rStr1,
const OUString rStr2 
)
friend
bool operator>= ( const OUString rStr1,
const OUString rStr2 
)
friend

The documentation for this class was generated from the following file: