:: rtl ::

class OString


Base Classes
None.
Known Derived Classes
None.

virtual abstract interface template
NO NO NO NO
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.
File
string.hxx

Public Members

Methods


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.
explicit
OString( sal_Char value ) throw( );
New string from a single character.

OString( const sal_Char * value ) throw( );
New string from a character buffer array.

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.
OString &
operator=( const OString & str ) throw( );
Assign a new string.
OString &
operator+=( const OString & str ) throw( );
Append a string to this string.
sal_Int32
getLength( ) const throw( );
Returns the length of this string.

operator const sal_Char *( ) const throw( );
Returns a pointer to the characters of this string.
const sal_Char *
getStr( ) const throw( );
Returns a pointer to the characters of this string.
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
equalsIgnoreAsciiCase( const OString & str ) 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.
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.
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( );
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.
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( );
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
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.
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 Methods

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.

Top of Page