UDK 3.2.7 C/C++ API Reference
Public Member Functions | Static Public Member Functions | Friends
rtl::OString Class Reference

This String class provide base functionality for C++ like 8-Bit character array handling. More...

#include <string.hxx>

List of all members.

Public Member Functions

 OString () throw ()
 New string containing no characters.
 OString (const OString &str) throw ()
 New string from OString.
 OString (rtl_String *str) throw ()
 New string from OString data.
 OString (rtl_String *str, __sal_NoAcquire) throw ()
 New string from OString data without acquiring it.
 OString (sal_Char value) throw ()
 New string from a single character.
template<typename T >
 OString (const T &value, typename internal::CharPtrDetector< T, internal::Dummy >::Type=internal::Dummy()) throw ()
 New string from a character buffer array.
template<typename T >
 OString (T &value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy()) throw ()
template<typename T >
 OString (T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy()) throw ()
 New string from a string literal.
 OString (const sal_Char *value, sal_Int32 length) throw ()
 New string from a character buffer array.
 OString (const sal_Unicode *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
 New string from a Unicode character buffer array.
 ~OString () throw ()
 Release the string data.
OStringoperator= (const OString &str) throw ()
 Assign a new string.
template<typename T >
internal::ConstCharArrayDetector
< T, OString & >::Type 
operator= (T &literal) 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.
OStringoperator+= (const OString &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_ChargetStr () const throw ()
 Returns a pointer to the characters of this string.
sal_Char operator[] (sal_Int32 index) const
 Access to individual characters.
sal_Int32 compareTo (const OString &str) const throw ()
 Compares two strings.
sal_Int32 compareTo (const OString &rObj, sal_Int32 maxLength) const throw ()
 Compares two strings with an maximum count of characters.
sal_Int32 reverseCompareTo (const OString &str) const throw ()
 Compares two strings in reverse order.
sal_Bool equals (const OString &str) const throw ()
 Perform a comparison of two strings.
sal_Bool equalsL (const sal_Char *value, sal_Int32 length) const throw ()
 Perform a comparison of two strings.
sal_Bool equalsIgnoreAsciiCase (const OString &str) const throw ()
 Perform a ASCII lowercase comparison of two strings.
template<typename T >
internal::CharPtrDetector< T,
bool >::Type 
equalsIgnoreAsciiCase (const T &asciiStr) const throw ()
 Perform a ASCII lowercase comparison of two strings.
template<typename T >
internal::NonConstCharArrayDetector
< T, bool >::Type 
equalsIgnoreAsciiCase (T &asciiStr) const throw ()
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 equalsIgnoreAsciiCaseL (const sal_Char *asciiStr, sal_Int32 asciiStrLength) const throw ()
 Perform a ASCII lowercase comparison of two strings.
sal_Bool match (const OString &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.
bool matchL (char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
 Match against a substring appearing in this string.
sal_Bool matchIgnoreAsciiCase (const OString &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
 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.
bool endsWith (OString const &str) const
 Check whether this string ends with a given substring.
template<typename T >
internal::ConstCharArrayDetector
< T, bool >::Type 
endsWith (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.
bool endsWithL (char const *str, sal_Int32 strLength) const
 Check whether this string ends with a given substring.
sal_Int32 hashCode () const throw ()
 Returns a hashcode for this string.
sal_Int32 indexOf (sal_Char ch, sal_Int32 fromIndex=0) const throw ()
 Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
sal_Int32 lastIndexOf (sal_Char ch) const throw ()
 Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
sal_Int32 lastIndexOf (sal_Char ch, sal_Int32 fromIndex) const throw ()
 Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
sal_Int32 indexOf (const OString &str, sal_Int32 fromIndex=0) const throw ()
 Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
template<typename T >
internal::ConstCharArrayDetector
< T, sal_Int32 >::Type 
indexOf (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 indexOfL (char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const throw ()
 Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
sal_Int32 lastIndexOf (const OString &str) const throw ()
 Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
sal_Int32 lastIndexOf (const OString &str, sal_Int32 fromIndex) const throw ()
 Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
OString copy (sal_Int32 beginIndex) const throw ()
 Returns a new string that is a substring of this string.
OString copy (sal_Int32 beginIndex, sal_Int32 count) const throw ()
 Returns a new string that is a substring of this string.
OString concat (const OString &str) const throw ()
 Concatenates the specified string to the end of this string.
OString replaceAt (sal_Int32 index, sal_Int32 count, const OString &newStr) const throw ()
 Returns a new string resulting from replacing n = count characters from position index in this string with newStr.
OString replace (sal_Char oldChar, sal_Char newChar) const throw ()
 Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
OString replaceFirst (OString const &from, OString const &to, sal_Int32 *index=0) const
 Returns a new string resulting from replacing the first occurrence of a given substring with another substring.
OString replaceAll (OString const &from, OString const &to) const
 Returns a new string resulting from replacing all occurrences of a given substring with another substring.
OString toAsciiLowerCase () const throw ()
 Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-122).
OString toAsciiUpperCase () const throw ()
 Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-90).
OString trim () const throw ()
 Returns a new string resulting from removing white space from both ends of the string.
OString getToken (sal_Int32 token, sal_Char cTok, sal_Int32 &index) const throw ()
 Returns a token in the string.
OString getToken (sal_Int32 count, char separator) const
 Returns a token from the string.
sal_Bool toBoolean () const throw ()
 Returns the Boolean value from this string.
sal_Char toChar () const throw ()
 Returns the first character from this string.
sal_Int32 toInt32 (sal_Int16 radix=10) const throw ()
 Returns the int32 value from this string.
sal_Int64 toInt64 (sal_Int16 radix=10) const throw ()
 Returns the int64 value from this string.
float toFloat () const throw ()
 Returns the float value from this string.
double toDouble () const throw ()
 Returns the double value from this string.

Static Public Member Functions

static OString valueOf (sal_Bool b) throw ()
 Returns the string representation of the sal_Bool argument.
static OString valueOf (sal_Char c) throw ()
 Returns the string representation of the char argument.
static OString valueOf (sal_Int32 i, sal_Int16 radix=10) throw ()
 Returns the string representation of the int argument.
static OString valueOf (sal_Int64 ll, sal_Int16 radix=10) throw ()
 Returns the string representation of the long argument.
static OString valueOf (float f) throw ()
 Returns the string representation of the float argument.
static OString valueOf (double d) throw ()
 Returns the string representation of the double argument.

Friends

sal_Bool operator== (const OString &rStr1, const OString &rStr2) throw ()
sal_Bool operator!= (const OString &rStr1, const OString &rStr2) throw ()
sal_Bool operator< (const OString &rStr1, const OString &rStr2) throw ()
sal_Bool operator> (const OString &rStr1, const OString &rStr2) throw ()
sal_Bool operator<= (const OString &rStr1, const OString &rStr2) throw ()
sal_Bool operator>= (const OString &rStr1, const OString &rStr2) throw ()
template<typename T >
internal::CharPtrDetector< T,
bool >::Type 
operator== (const OString &rStr1, const T &value) throw ()
template<typename T >
internal::NonConstCharArrayDetector
< T, bool >::Type 
operator== (const OString &rStr1, T &value) throw ()
template<typename T >
internal::CharPtrDetector< T,
bool >::Type 
operator== (const T &value, const OString &rStr2) throw ()
template<typename T >
internal::NonConstCharArrayDetector
< T, bool >::Type 
operator== (T &value, const OString &rStr2) throw ()
template<typename T >
internal::ConstCharArrayDetector
< T, bool >::Type 
operator== (const OString &rStr, T &literal) 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.
template<typename T >
internal::ConstCharArrayDetector
< T, bool >::Type 
operator== (T &literal, const OString &rStr) 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.
template<typename T >
internal::CharPtrDetector< T,
bool >::Type 
operator!= (const OString &rStr1, const T &value) throw ()
template<typename T >
internal::NonConstCharArrayDetector
< T, bool >::Type 
operator!= (const OString &rStr1, T &value) throw ()
template<typename T >
internal::CharPtrDetector< T,
bool >::Type 
operator!= (const T &value, const OString &rStr2) throw ()
template<typename T >
internal::NonConstCharArrayDetector
< T, bool >::Type 
operator!= (T &value, const OString &rStr2) throw ()
template<typename T >
internal::ConstCharArrayDetector
< T, bool >::Type 
operator!= (const OString &rStr, T &literal) 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.
template<typename T >
internal::ConstCharArrayDetector
< T, bool >::Type 
operator!= (T &literal, const OString &rStr) 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.
OString operator+ (const OString &str1, const OString &str2) throw ()

Detailed Description

This String class provide base functionality for C++ like 8-Bit character array handling.

The advantage of this class is, that it handle all the memory managament for you - and it do it more efficient. 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 stores also the length of the string, so that many operations are faster as the C-str-functions.

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

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


Constructor & Destructor Documentation

rtl::OString::OString ( ) throw () [inline]

New string containing no characters.

rtl::OString::OString ( const OString str) throw () [inline]

New string from OString.

Parameters:
stra OString.
rtl::OString::OString ( rtl_String *  str) throw () [inline]

New string from OString data.

Parameters:
stra OString data.
rtl::OString::OString ( rtl_String *  str,
__sal_NoAcquire   
) throw () [inline]

New string from OString data without acquiring it.

Takeover of ownership.

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

Parameters:
stra OString data.
rtl::OString::OString ( sal_Char  value) throw () [inline, explicit]

New string from a single character.

Parameters:
valuea character.
template<typename T >
rtl::OString::OString ( const T &  value,
typename internal::CharPtrDetector< T, internal::Dummy >::Type  = internal::Dummy() 
) throw () [inline]

New string from a character buffer array.

Note: The argument type is always either char* or const char*. The template is used only for technical reasons, as is the second argument.

Parameters:
valuea NULL-terminated character array.
template<typename T >
rtl::OString::OString ( T &  value,
typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type  = internal::Dummy() 
) throw () [inline]
template<typename T >
rtl::OString::OString ( T &  literal,
typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type  = internal::Dummy() 
) throw () [inline]

New string from a string literal.

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

Since:
LibreOffice 3.6
Parameters:
literala string literal
rtl::OString::OString ( const sal_Char value,
sal_Int32  length 
) throw () [inline]

New string from a character buffer array.

Parameters:
valuea character array.
lengththe number of character which should be copied. The character array length must be greater or equal than this value.
rtl::OString::OString ( const sal_Unicode value,
sal_Int32  length,
rtl_TextEncoding  encoding,
sal_uInt32  convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS 
) [inline]

New string from a Unicode character buffer array.

Parameters:
valuea Unicode character array.
lengththe number of character which should be converted. The Unicode character array length must be greater or equal than this value.
encodingthe text encoding in which the Unicode character sequence should be converted.
convertFlagsflags which controls the conversion. see RTL_UNICODETOTEXT_FLAGS_...
Exceptions:
std::bad_allocis thrown if an out-of-memory condition occurs
rtl::OString::~OString ( ) throw () [inline]

Release the string data.


Member Function Documentation

sal_Int32 rtl::OString::compareTo ( const OString str) const throw () [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::OString::compareTo ( const OString rObj,
sal_Int32  maxLength 
) const throw () [inline]

Compares two strings with an 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:
rObjthe 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
OString rtl::OString::concat ( const OString str) const throw () [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.
OString rtl::OString::copy ( sal_Int32  beginIndex) const throw () [inline]

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

The substring begins at the specified beginIndex. It is an error for beginIndex to be negative or to be greater than the length of this string.

Parameters:
beginIndexthe beginning index, inclusive.
Returns:
the specified substring.
OString rtl::OString::copy ( sal_Int32  beginIndex,
sal_Int32  count 
) const throw () [inline]

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

The substring begins at the specified beginIndex and contains count characters. It is an error for either beginIndex or count to be negative, or for beginIndex + count to be greater than the length of this string.

Parameters:
beginIndexthe beginning index, inclusive.
countthe number of characters.
Returns:
the specified substring.
bool rtl::OString::endsWith ( OString const &  str) const [inline]

Check whether this string ends with a given substring.

Parameters:
strthe substring to be compared
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 >
internal::ConstCharArrayDetector< T, bool >::Type rtl::OString::endsWith ( 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::OString::endsWithL ( char const *  str,
sal_Int32  strLength 
) const [inline]

Check whether this string ends with a given substring.

Parameters:
strthe substring to be compared; must not be null and must point to memory of at least strLength bytes
strLengththe length of the substring; must be non-negative
Returns:
true if and only if the given str appears as a substring at the end of this string
Since:
LibreOffice 3.6
sal_Bool rtl::OString::equals ( const OString str) const throw () [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:
sal_True if the strings are equal; sal_False, otherwise.
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type rtl::OString::equalsIgnoreAsciiCase ( T &  literal) const throw () [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_Bool rtl::OString::equalsIgnoreAsciiCase ( const OString str) const throw () [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:
sal_True if the strings are equal; sal_False, otherwise.
template<typename T >
internal::CharPtrDetector< T, bool >::Type rtl::OString::equalsIgnoreAsciiCase ( const T &  asciiStr) const throw () [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 127. The ASCII string must be NULL-terminated. This function can't be used for language specific comparison.

Note: The argument type is always either char* or const char*, the return type is bool. The template is used only for technical reasons.

Parameters:
asciiStrthe 8-Bit ASCII character string to be compared.
Returns:
sal_True if the strings are equal; sal_False, otherwise.
template<typename T >
internal::NonConstCharArrayDetector< T, bool >::Type rtl::OString::equalsIgnoreAsciiCase ( T &  asciiStr) const throw () [inline]
sal_Bool rtl::OString::equalsIgnoreAsciiCaseL ( const sal_Char asciiStr,
sal_Int32  asciiStrLength 
) const throw () [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 127. The ASCII string must be greater or equal in length as 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:
sal_True if the strings are equal; sal_False, otherwise.
sal_Bool rtl::OString::equalsL ( const sal_Char value,
sal_Int32  length 
) const throw () [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. The ASCII string must be NULL-terminated and must be greater or equal as length. This function can't be used for language specific comparison.

Parameters:
valuea character array.
lengththe length of the character array.
Returns:
sal_True if the strings are equal; sal_False, otherwise.
sal_Int32 rtl::OString::getLength ( ) const throw () [inline]

Returns the length of this string.

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

Returns:
the length of the sequence of characters represented by this object.
const sal_Char* rtl::OString::getStr ( ) const throw () [inline]

Returns a pointer to the characters of this string.

The returned pointer is guaranteed to point to a null-terminated byte string. But note that this string object may contain embedded null characters, which will thus also be embedded in the returned null-terminated byte string.

Returns:
a pointer to a null-terminated byte string representing the characters of this string object.
OString rtl::OString::getToken ( sal_Int32  token,
sal_Char  cTok,
sal_Int32 &  index 
) const throw () [inline]

Returns a token in the string.

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

Parameters:
tokenthe number of the token to return.
cTokthe character which seperate the tokens.
indexthe position at which the token is searched in the string. The index must not be greater thanthe 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)
OString rtl::OString::getToken ( sal_Int32  count,
char  separator 
) const [inline]

Returns a token from the string.

The same as getToken(sal_Int32, sal_Char, 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::OString::hashCode ( ) const throw () [inline]

Returns a hashcode for this string.

Returns:
a hash code value for this object.
See also:
rtl::OStringHash for convenient use of boost::unordered_map
sal_Int32 rtl::OString::indexOf ( sal_Char  ch,
sal_Int32  fromIndex = 0 
) const throw () [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 or equal than 0 and less or equal as 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::OString::indexOf ( const OString str,
sal_Int32  fromIndex = 0 
) const throw () [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 >
internal::ConstCharArrayDetector< T, sal_Int32 >::Type rtl::OString::indexOf ( T &  literal,
sal_Int32  fromIndex = 0 
) const throw () [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::OString::indexOfL ( char const *  str,
sal_Int32  len,
sal_Int32  fromIndex = 0 
) const throw () [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.
lenthe length of the substring.
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.
Since:
LibreOffice 3.6
bool rtl::OString::isEmpty ( ) const throw () [inline]

Checks if a string is empty.

Returns:
sal_True if the string is empty; sal_False, otherwise.
Since:
LibreOffice 3.4
sal_Int32 rtl::OString::lastIndexOf ( const OString str) const throw () [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::OString::lastIndexOf ( const OString str,
sal_Int32  fromIndex 
) const throw () [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.
sal_Int32 rtl::OString::lastIndexOf ( sal_Char  ch) const throw () [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::OString::lastIndexOf ( sal_Char  ch,
sal_Int32  fromIndex 
) const throw () [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_Bool rtl::OString::match ( const OString str,
sal_Int32  fromIndex = 0 
) const throw () [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 or equal than 0 and less or equal as the string length.
Returns:
sal_True if str match with the characters in the string at the given position; sal_False, otherwise.
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type rtl::OString::match ( T &  literal,
sal_Int32  fromIndex = 0 
) const throw () [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_Bool rtl::OString::matchIgnoreAsciiCase ( const OString str,
sal_Int32  fromIndex = 0 
) const throw () [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 or equal than 0 and less or equal as the string length.
Returns:
sal_True if str match with the characters in the string at the given position; sal_False, otherwise.
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type rtl::OString::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::OString::matchL ( char const *  str,
sal_Int32  strLength,
sal_Int32  fromIndex = 0 
) const [inline]

Match against a substring appearing in this string.

Parameters:
strthe substring to be compared; must not be null and must point to memory of at least strLength bytes
strLengththe length of the substring; must be non-negative
fromIndexthe index into this string to start the comparison at; must be non-negative and not greater than this string's length
Returns:
true if and only if the given str is contained as a substring of this string at the given fromIndex
Since:
LibreOffice 3.6
OString& rtl::OString::operator+= ( const OString str) throw () [inline]

Append a string to this string.

Parameters:
stra OString.
template<typename T >
internal::ConstCharArrayDetector< T, OString& >::Type rtl::OString::operator= ( T &  literal) throw () [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
OString& rtl::OString::operator= ( const OString str) throw () [inline]

Assign a new string.

Parameters:
stra OString.
sal_Char rtl::OString::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
OString rtl::OString::replace ( sal_Char  oldChar,
sal_Char  newChar 
) const throw () [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.
OString rtl::OString::replaceAll ( OString const &  from,
OString 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:
fromthe substring to be replaced
tothe replacing substring
Since:
LibreOffice 3.6
OString rtl::OString::replaceAt ( sal_Int32  index,
sal_Int32  count,
const OString newStr 
) const throw () [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 or equal as 0 and less or equal as the length of the string.
countthe count of charcters that will replaced The count must be greater or equal as 0 and less or equal as the length of the string minus index.
newStrthe new substring.
Returns:
the new string.
OString rtl::OString::replaceFirst ( OString const &  from,
OString const &  to,
sal_Int32 *  index = 0 
) 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 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 exit from 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::OString::reverseCompareTo ( const OString str) const throw () [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
OString rtl::OString::toAsciiLowerCase ( ) const throw () [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.
OString rtl::OString::toAsciiUpperCase ( ) const throw () [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.
sal_Bool rtl::OString::toBoolean ( ) const throw () [inline]

Returns the Boolean value from this string.

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

Returns:
sal_True, if the string is 1 or "True" in any ASCII case. sal_False in any other case.
sal_Char rtl::OString::toChar ( ) const throw () [inline]

Returns the first character from this string.

Returns:
the first character from this string or 0, if this string is emptry.
double rtl::OString::toDouble ( ) const throw () [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::OString::toFloat ( ) const throw () [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::OString::toInt32 ( sal_Int16  radix = 10) const throw () [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.
sal_Int64 rtl::OString::toInt64 ( sal_Int16  radix = 10) const throw () [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.
OString rtl::OString::trim ( ) const throw () [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 OString rtl::OString::valueOf ( sal_Bool  b) throw () [inline, static]

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.
static OString rtl::OString::valueOf ( sal_Int32  i,
sal_Int16  radix = 10 
) throw () [inline, static]

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.
static OString rtl::OString::valueOf ( sal_Int64  ll,
sal_Int16  radix = 10 
) throw () [inline, static]

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.
static OString rtl::OString::valueOf ( double  d) throw () [inline, static]

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.
static OString rtl::OString::valueOf ( float  f) throw () [inline, static]

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.
static OString rtl::OString::valueOf ( sal_Char  c) throw () [inline, static]

Returns the string representation of the char argument.

Parameters:
ca character.
Returns:
a string with the string representation of the argument.

Friends And Related Function Documentation

sal_Bool operator!= ( const OString rStr1,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::NonConstCharArrayDetector< T, bool >::Type operator!= ( T &  value,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type operator!= ( const OString rStr,
T &  literal 
) throw () [friend]

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
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type operator!= ( T &  literal,
const OString rStr 
) throw () [friend]

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
template<typename T >
internal::CharPtrDetector< T, bool >::Type operator!= ( const OString rStr1,
const T &  value 
) throw () [friend]
template<typename T >
internal::NonConstCharArrayDetector< T, bool >::Type operator!= ( const OString rStr1,
T &  value 
) throw () [friend]
template<typename T >
internal::CharPtrDetector< T, bool >::Type operator!= ( const T &  value,
const OString rStr2 
) throw () [friend]
OString operator+ ( const OString str1,
const OString str2 
) throw () [friend]
sal_Bool operator< ( const OString rStr1,
const OString rStr2 
) throw () [friend]
sal_Bool operator<= ( const OString rStr1,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::NonConstCharArrayDetector< T, bool >::Type operator== ( T &  value,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::CharPtrDetector< T, bool >::Type operator== ( const T &  value,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type operator== ( const OString rStr,
T &  literal 
) throw () [friend]

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
template<typename T >
internal::CharPtrDetector< T, bool >::Type operator== ( const OString rStr1,
const T &  value 
) throw () [friend]
template<typename T >
internal::NonConstCharArrayDetector< T, bool >::Type operator== ( const OString rStr1,
T &  value 
) throw () [friend]
sal_Bool operator== ( const OString rStr1,
const OString rStr2 
) throw () [friend]
template<typename T >
internal::ConstCharArrayDetector< T, bool >::Type operator== ( T &  literal,
const OString rStr 
) throw () [friend]

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_Bool operator> ( const OString rStr1,
const OString rStr2 
) throw () [friend]
sal_Bool operator>= ( const OString rStr1,
const OString rStr2 
) throw () [friend]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines