LibreOffice LibreOffice 4.1 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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::OString Class Reference

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

`#include <string.hxx>`

## Public Member Functions
| OString () throw ()
| New string containing no characters. More...
| OString (const OString &str) throw ()
| New string from OString. More...
| OString (rtl_String *str) throw ()
| New string from OString data. More...
| OString (rtl_String *str, __sal_NoAcquire) throw ()
| New string from OString data without acquiring it. More...
| OString (sal_Char value) throw ()
| New string from a single character. More...
template<typename T >
| OString (const T &value, typename internal::CharPtrDetector< T, internal::Dummy >::Type=internal::Dummy()) throw ()
| New string from a character buffer array. More...
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. More...
| OString (const sal_Char *value, sal_Int32 length) throw ()
| New string from a character buffer array. More...
| 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. More...
| ~OString () throw ()
| Release the string data. More...
OString & | operator= (const OString &str) throw ()
| Assign a new string. More...
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. More...
OString & | operator+= (const OString &str) throw ()
| Append a string to this string. More...
sal_Int32 | getLength () const throw ()
| Returns the length of this string. More...
bool | isEmpty () const throw ()
| Checks if a string is empty. More...
const sal_Char * | getStr () const throw ()
| Returns a pointer to the characters of this string. More...
sal_Char | operator[] (sal_Int32 index) const
| Access to individual characters. More...
sal_Int32 | compareTo (const OString &str) const throw ()
| Compares two strings. More...
sal_Int32 | compareTo (const OString &rObj, sal_Int32 maxLength) const throw ()
| Compares two strings with an maximum count of characters. More...
sal_Int32 | reverseCompareTo (const OString &str) const throw ()
| Compares two strings in reverse order. More...
sal_Bool | equals (const OString &str) const throw ()
| Perform a comparison of two strings. More...
sal_Bool | equalsL (const sal_Char *value, sal_Int32 length) const throw ()
| Perform a comparison of two strings. More...
sal_Bool | equalsIgnoreAsciiCase (const OString &str) const throw ()
| Perform a ASCII lowercase comparison of two strings. More...
template<typename T >
internal::CharPtrDetector< T, bool >::Type | equalsIgnoreAsciiCase (const T &asciiStr) const throw ()
| Perform a ASCII lowercase comparison of two strings. More...
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. More...
sal_Bool | equalsIgnoreAsciiCaseL (const sal_Char *asciiStr, sal_Int32 asciiStrLength) const throw ()
| Perform a ASCII lowercase comparison of two strings. More...
sal_Bool | match (const OString &str, sal_Int32 fromIndex=0) const throw ()
| Match against a substring appearing in this string. More...
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. More...
bool | matchL (char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
| Match against a substring appearing in this string. More...
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. More...
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. More...
bool | startsWith (OString const &str) const
| Check whether this string starts with a given substring. More...
template<typename T >
internal::ConstCharArrayDetector < T, bool >::Type | startsWith (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 | endsWith (OString const &str) const
| Check whether this string ends with a given substring. More...
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. More...
bool | endsWithL (char const *str, sal_Int32 strLength) const
| Check whether this string ends with a given substring. More...
sal_Int32 | hashCode () const throw ()
| Returns a hashcode for this string. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
SAL_WARN_UNUSED_RESULT OString | copy (sal_Int32 beginIndex) const throw ()
| Returns a new string that is a substring of this string. More...
SAL_WARN_UNUSED_RESULT OString | copy (sal_Int32 beginIndex, sal_Int32 count) const throw ()
| Returns a new string that is a substring of this string. More...
SAL_WARN_UNUSED_RESULT OString | concat (const OString &str) const throw ()
| Concatenates the specified string to the end of this string. More...
SAL_WARN_UNUSED_RESULT 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. More...
SAL_WARN_UNUSED_RESULT 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. More...
SAL_WARN_UNUSED_RESULT 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. More...
SAL_WARN_UNUSED_RESULT OString | replaceAll (OString const &from, OString const &to) const
| Returns a new string resulting from replacing all occurrences of a given substring with another substring. More...
SAL_WARN_UNUSED_RESULT OString | toAsciiLowerCase () const throw ()
| Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-122). More...
SAL_WARN_UNUSED_RESULT OString | toAsciiUpperCase () const throw ()
| Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-90). More...
SAL_WARN_UNUSED_RESULT OString | trim () const throw ()
| Returns a new string resulting from removing white space from both ends of the string. More...
OString | getToken (sal_Int32 token, sal_Char cTok, sal_Int32 &index) const throw ()
| Returns a token in the string. More...
OString | getToken (sal_Int32 count, char separator) const
| Returns a token from the string. More...
sal_Bool | toBoolean () const throw ()
| Returns the Boolean value from this string. More...
sal_Char | toChar () const throw ()
| Returns the first character from this string. More...
sal_Int32 | toInt32 (sal_Int16 radix=10) const throw ()
| Returns the int32 value from this string. More...
sal_Int64 | toInt64 (sal_Int16 radix=10) const throw ()
| Returns the int64 value from this string. More...
sal_uInt64 | toUInt64 (sal_Int16 radix=10) const throw ()
| Returns the uint64 value from this string. More...
float | toFloat () const throw ()
| Returns the float value from this string. More...
double | toDouble () const throw ()
| Returns the double value from this string. More...
use | boolean ()") static OString valueOf( sal_Bool b ) throw ()
| Returns the string representation of the sal_Bool argument. More...
use | number ()") static OString valueOf( sal_Int32 i
| Returns the string representation of the int argument. More...

## Static Public Member Functions
static OString | number (int i, sal_Int16 radix=10)
| Returns the string representation of the integer argument. More...
static OString | number (unsigned int i, sal_Int16 radix=10)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
static OString | 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 OString | 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 OString | 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 OString | number (unsigned long long ll, sal_Int16 radix=10)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
static OString | number (float f)
| Returns the string representation of the float argument. More...
static OString | number (double d)
| Returns the string representation of the double argument. More...
static OString | boolean (bool b) throw ()
| Returns the string representation of the boolean argument. More...
convert to OString or use static directly OString | valueOf (sal_Char c) throw ()
| Returns the string representation of the char argument. More...

## 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. More...
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. More...
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. More...
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. More...
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

  str | a OString.

rtl::OString::OString | ( | rtl_String * | str | ) |
throw | ( |
| ) |  |
| inline

New string from OString data.

Parameters

  str | a 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

  str | a OString data.

rtl::OString::OString | ( | sal_Char | value | ) |
throw | ( |
| ) |  |
| inline explicit

New string from a single character.

Parameters

  value | a 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

  value | a 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

  literal | a string literal

rtl::OString::OString | ( | const sal_Char * | value,
|  | sal_Int32 | length
| ) |  |
throw | ( |
| ) |  |
| inline

New string from a character buffer array.

Parameters

  value | a character array.
  length | the 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

  value | a Unicode character array.
  length | the number of character which should be converted. The Unicode character array length must be greater or equal than this value.
  encoding | the text encoding in which the Unicode character sequence should be converted.
  convertFlags | flags which controls the conversion. see RTL_UNICODETOTEXT_FLAGS_...

Exceptions

  std::bad_alloc | is thrown if an out-of-memory condition occurs

rtl::OString::~OString | ( |  | ) |
throw | ( |
| ) |  |
| inline

Release the string data.

## Member Function Documentation

use rtl::OString::boolean | ( |  | ) |
throw | ( |
| ) |  |
| inline

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

  b | a sal_Bool.

Returns
  a string with the string representation of the argument.

Deprecated:
  use boolean()

static OString rtl::OString::boolean | ( | bool | b | ) |
throw | ( |
| ) |  |
| inline static

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

  b | a bool.

Returns
  a string with the string representation of the argument.

Since
  LibreOffice 4.1

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

  str | the 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

  rObj | the object to be compared.
  maxLength | the 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_WARN_UNUSED_RESULT OString rtl::OString::concat | ( | const OString & | str | ) | const
throw | ( |
| ) |  |
| inline

Concatenates the specified string to the end of this string.

Parameters

  str | the 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.

SAL_WARN_UNUSED_RESULT 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. If beginIndex is negative or be greater than the length of this string, behaviour is undefined.

Parameters

  beginIndex | the beginning index, inclusive.

Returns
  the specified substring.

SAL_WARN_UNUSED_RESULT 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. If either beginIndex or count are negative, or beginIndex + count are greater than the length of this string then behaviour is undefined.

Parameters

  beginIndex | the beginning index, inclusive.
  count | the 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

  str | the 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

  str | the substring to be compared; must not be null and must point to memory of at least strLength bytes
  strLength | the 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

  str | the object to be compared.

Returns
  sal_True if the strings are equal; sal_False, otherwise.

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

  str | the 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

1. 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

  asciiStr | the 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

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::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

1. The ASCII string must be greater or equal in length as asciiStrLength. This function can't be used for language specific comparison.

Parameters

  asciiStr | the 8-Bit ASCII character string to be compared.
  asciiStrLength | the 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

  value | a character array.
  length | the 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

  token | the number of the token to return.
  cTok | the character which separate the tokens.
  index | the 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

  count | the number of the token to return, starting with 0
  separator | the 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

  ch | character to be located.
  fromIndex | the 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

  str | the substring to search for.
  fromIndex | the 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

  str | the substring to search for.
  len | the length of the substring.
  fromIndex | the 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
  true if the string is empty; false, otherwise.

Since
  LibreOffice 3.4

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

  ch | character 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

  ch | character to be located.
  fromIndex | the 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::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

  str | the 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

  str | the substring to search for.
  fromIndex | the 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_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

  str | the object (substring) to be compared.
  fromIndex | the 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

  str | the object (substring) to be compared.
  fromIndex | the 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

  str | the substring to be compared; must not be null and must point to memory of at least strLength bytes
  strLength | the length of the substring; must be non-negative
  fromIndex | the 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

static OString rtl::OString::number | ( | int | i,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

Returns the string representation of the integer argument.

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

Parameters

  i | an integer value
  radix | the radix (between 2 and 36)

Returns
  a string with the string representation of the argument.

Since
  LibreOffice 4.1

static OString rtl::OString::number | ( | unsigned int | i,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

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 OString rtl::OString::number | ( | long | i,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

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 OString rtl::OString::number | ( | unsigned long | i,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

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 OString rtl::OString::number | ( | long long | ll,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

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 OString rtl::OString::number | ( | unsigned long long | ll,
|  | sal_Int16 | radix = `10`
| ) |  |
| inline static

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 OString rtl::OString::number | ( | float | f | ) |
| inline static

Returns the string representation of the float argument.

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

Parameters

  f | a float.

Returns
  a string with the string representation of the argument.

Since
  LibreOffice 4.1

static OString rtl::OString::number | ( | double | d | ) |
| inline static

Returns the string representation of the double argument.

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

Parameters

  d | a double.

Returns
  a string with the string representation of the argument.

Since
  LibreOffice 4.1

use rtl::OString::number | ( |  | ) |

Returns the string representation of the int argument.

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

Parameters

  i | a int32.
  radix | the radix (between 2 and 36)

Returns
  a string with the string representation of the argument.

Deprecated:
  use number()

OString& rtl::OString::operator+= | ( | const OString & | str | ) |
throw | ( |
| ) |  |
| inline

Append a string to this string.

Parameters

  str | a OString.

OString& rtl::OString::operator= | ( | const OString & | str | ) |
throw | ( |
| ) |  |
| inline

Assign a new string.

Parameters

  str | a 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

sal_Char rtl::OString::operator[] | ( | sal_Int32 | index | ) | const
| inline

Access to individual characters.

Parameters

  index | must be non-negative and less than length.

Returns
  the character at the given index.

Since
  LibreOffice 3.5

SAL_WARN_UNUSED_RESULT 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

  oldChar | the old character.
  newChar | the new character.

Returns
  a string derived from this string by replacing every occurrence of oldChar with newChar.

SAL_WARN_UNUSED_RESULT 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

  from | the substring to be replaced
  to | the replacing substring

Since
  LibreOffice 3.6

SAL_WARN_UNUSED_RESULT 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

  index | the replacing index in str. The index must be greater or equal as 0 and less or equal as the length of the string.
  count | the count of characters that will replaced The count must be greater or equal as 0 and less or equal as the length of the string minus index.
  newStr | the new substring.

Returns
  the new string.

SAL_WARN_UNUSED_RESULT 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

  | from | the substring to be replaced
  | to | the replacing substring
  [in,out] | index | pointer 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

  str | the 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

bool rtl::OString::startsWith | ( | OString const & | str | ) | const
| inline

Check whether this string starts with a given substring.

Parameters

  str | the substring to be compared

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 >

internal::ConstCharArrayDetector< T, bool >::Type rtl::OString::startsWith | ( | 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.0

SAL_WARN_UNUSED_RESULT 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.

SAL_WARN_UNUSED_RESULT 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

  radix | the 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

  radix | the radix (between 2 and 36)

Returns
  the int64 represented from this string. 0 if this string represents no number.

sal_uInt64 rtl::OString::toUInt64 | ( | sal_Int16 | radix = `10` | ) | const
throw | ( |
| ) |  |
| inline

Returns the uint64 value from this string.

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

Parameters

  radix | the 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

SAL_WARN_UNUSED_RESULT 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.

convert to OString or use static directly OString rtl::OString::valueOf | ( | sal_Char | c | ) |
throw | ( |
| ) |  |
| inline static

Returns the string representation of the char argument.

Parameters

  c | a character.

Returns
  a string with the string representation of the argument.

Deprecated:
  use operator, function or constructor taking char or sal_Unicode argument

## Friends And Related Function Documentation

sal_Bool operator!= | ( | const OString & | rStr1,
|  | const OString & | rStr2
| ) |  |
throw | ( |
| ) |  |
| friend

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

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

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

sal_Bool operator== | ( | const OString & | rStr1,
|  | const OString & | rStr2
| ) |  |
throw | ( |
| ) |  |
| friend

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

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

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:

- rtl/string.hxx