LibreOffice
LibreOffice 4.1 SDK C/C++ API Reference
|
This String class provides base functionality for C++ like Unicode character array handling. More...
#include <ustring.hxx>
Classes | |
class | DO_NOT_ACQUIRE |
Public Member Functions | |
OUString () throw () | |
New string containing no characters. | |
OUString (const OUString &str) throw () | |
New string from OUString. | |
OUString (rtl_uString *str) throw () | |
New string from OUString data. | |
OUString (rtl_uString *str, __sal_NoAcquire) throw () | |
New OUString from OUString data without acquiring it. | |
OUString (sal_Unicode value) throw () | |
New string from a single Unicode character. | |
OUString (const sal_Unicode *value) throw () | |
New string from a Unicode character buffer array. | |
OUString (const sal_Unicode *value, sal_Int32 length) throw () | |
New string from a Unicode character buffer array. | |
template<typename T > | |
OUString (T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy()) | |
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set (i.e. | |
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. | |
OUString (sal_uInt32 const *codePoints, sal_Int32 codePointCount) | |
Create a new string from an array of Unicode code points. | |
~OUString () throw () | |
Release the string data. | |
OUString & | operator= (const OUString &str) throw () |
Assign a new string. | |
template<typename T > | |
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. | |
OUString & | operator+= (const OUString &str) throw () |
Append a string to this string. | |
sal_Int32 | getLength () const throw () |
Returns the length of this string. | |
bool | isEmpty () const throw () |
Checks if a string is empty. | |
const sal_Unicode * | getStr () const throw () |
Returns a pointer to the Unicode character buffer for this string. | |
sal_Unicode | operator[] (sal_Int32 index) const |
Access to individual characters. | |
sal_Int32 | compareTo (const OUString &str) const throw () |
Compares two strings. | |
sal_Int32 | compareTo (const OUString &str, sal_Int32 maxLength) const throw () |
Compares two strings with a maximum count of characters. | |
sal_Int32 | reverseCompareTo (const OUString &str) const throw () |
Compares two strings in reverse order. | |
template<typename T > | |
internal::ConstCharArrayDetector < T, sal_Int32 >::Type | reverseCompareTo (T &literal) const throw () |
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. | |
sal_Bool | equals (const OUString &str) const throw () |
Perform a comparison of two strings. | |
sal_Bool | equalsIgnoreAsciiCase (const OUString &str) const throw () |
Perform a ASCII lowercase comparison of two strings. | |
sal_Int32 | compareToIgnoreAsciiCase (const OUString &str) const throw () |
Perform a ASCII lowercase comparison of two strings. | |
template<typename T > | |
internal::ConstCharArrayDetector < T, bool >::Type | equalsIgnoreAsciiCase (T &literal) const throw () |
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. | |
sal_Bool | match (const OUString &str, sal_Int32 fromIndex=0) const throw () |
Match against a substring appearing in this string. | |
template<typename T > | |
internal::ConstCharArrayDetector < T, bool >::Type | match (T &literal, sal_Int32 fromIndex=0) const throw () |
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. | |
sal_Bool | matchIgnoreAsciiCase (const OUString &str, sal_Int32 fromIndex=0) const throw () |
Match against a substring appearing in this string, ignoring the case of ASCII letters. | |
template<typename T > | |
internal::ConstCharArrayDetector < T, bool >::Type | matchIgnoreAsciiCase (T &literal, sal_Int32 fromIndex=0) const throw () |
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. | |
sal_Int32 | compareToAscii (const sal_Char *asciiStr) const throw () |
Compares two strings. |
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. |
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.
|
inline |
New string containing no characters.
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
New string from a single Unicode character.
value | a Unicode character. |
|
inline |
New string from a Unicode character buffer array.
value | a NULL-terminated Unicode character array. |
|
inline |
New string from a Unicode character buffer array.
value | a Unicode character array. |
length | the number of character which should be copied. The character array length must be greater than or equal to this value. |
|
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.
literal | the 8-bit ASCII string literal |
|
inline |
New string from an 8-Bit character buffer array.
value | An 8-Bit character array. |
length | The number of character which should be converted. The 8-Bit character array length must be greater than or equal to this value. |
encoding | The text encoding from which the 8-Bit character sequence should be converted. |
convertFlags | Flags which control the conversion. see RTL_TEXTTOUNICODE_FLAGS_... |
std::bad_alloc | is thrown if an out-of-memory condition occurs |
|
inlineexplicit |
Create a new string from an array of Unicode code points.
codePoints | an 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. |
codePointCount | the non-negative number of code points. |
std::bad_alloc | is 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. |
|
inline |
Release the string data.
|
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.
str | the object to be compared. |
|
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.
str | the object to be compared. |
maxLength | the maximum count of characters to be compared. |
|
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
asciiStr | the 8-Bit ASCII character string to be compared. |
|
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.
str | the object to be compared. |
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.
str | the object to be compared. |
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.
str | the object to be compared. |
|
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.
|
inline |
Returns the length of this string.
The length is equal to the number of Unicode characters in this string.
|
inline |
Returns a pointer to the Unicode character buffer for this string.
It isn't necessarily NULL terminated.
|
inline |
Checks if a string is empty.
|
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.
str | the object (substring) to be compared. |
fromIndex | the index to start the comparion from. The index must be greater than or equal to 0 and less or equal as the string length. |
|
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.
|
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.
str | the object (substring) to be compared. |
fromIndex | the 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. |
|
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.
Append a string to this string.
str | a OUString. |
Assign a new string.
str | a OUString. |
|
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.
literal | the 8-bit ASCII string literal |
|
inline |
Access to individual characters.
index | must be non-negative and less than length. |
|
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.
str | the object to be compared. |
|
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.
|
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.
ppHandle | pointer to storage |