Language:

The Free and Open Productivity Suite
Apache OpenOffice 4.1.4 released

Developer's Guide

API

SDK

Tips 'n' Tricks

Miscellaneous


:: rtl ::

class OUString


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 Unicode 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
ustring.hxx

Public Members

Methods


OUString( ) throw( );
New string containing no characters.

OUString( const OUString & str ) throw( );
New string from OUString.

OUString( rtl_uString * str ) throw( );
New string from OUString data.

OUString( rtl_uString * str, __sal_NoAcquire ) throw( );
New OUString from OUString data without acquiring it. Takeover of ownership.
explicit
OUString( sal_Unicode value ) throw( );
New string from a single Unicode character.

OUString( const sal_Unicode * value ) throw( );
New string from a Unicode character buffer array.

OUString( const sal_Unicode * value, sal_Int32 length ) throw( );
New string from a Uniocde character buffer array.

OUString( const sal_Char * value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS );
New string from a 8-Bit character buffer array.
explicit
OUString( const sal_uInt32 * codePoints, sal_Int32 codePointCount );
Create a new string from an array of Unicode code points.

~OUString( ) throw( );
Release the string data.
OUString &
operator=( const OUString & str ) throw( );
Assign a new string.
OUString &
operator+=( const OUString & str ) throw( );
Append a string to this string.
sal_Int32
getLength( ) const throw( );
Returns the length of this string.

operator const sal_Unicode *( ) const throw( );
Returns a pointer to the Unicode character buffer from this string.
const sal_Unicode *
getStr( ) const throw( );
Returns a pointer to the Unicode character buffer from this string.
sal_Int32
compareTo( const OUString & str ) const throw( );
Compares two strings.
sal_Int32
compareTo( const OUString & str, sal_Int32 maxLength ) const throw( );
Compares two strings with an maximum count of characters.
sal_Int32
reverseCompareTo( const OUString & str ) const throw( );
Compares two strings in reverse order.
sal_Bool
equals( const OUString & str ) const throw( );
Perform a comparison of two strings.
sal_Bool
equalsIgnoreAsciiCase( const OUString & str ) const throw( );
Perform a ASCII lowercase comparison of two strings.
sal_Bool
match( const OUString & str, sal_Int32 fromIndex = 0 ) const throw( );
Match against a substring appearing in this string.
sal_Bool
matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const throw( );
Match against a substring appearing in this string, ignoring the case of ASCII letters.
sal_Int32
compareToAscii( const sal_Char * asciiStr ) const throw( );
Compares two strings.
sal_Int32
compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const throw( );
Compares two strings with an maximum count of characters.
sal_Int32
reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const throw( );
Compares two strings in reverse order.
sal_Bool
equalsAscii( const sal_Char * asciiStr ) const throw( );
Perform a comparison of two strings.
sal_Bool
equalsAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const throw( );
Perform a comparison of two strings.
sal_Bool
equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const throw( );
Perform a ASCII lowercase comparison of two strings.
sal_Bool
equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const throw( );
Perform a ASCII lowercase comparison of two strings.
sal_Bool
matchAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const throw( );
Match against a substring appearing in this string.
sal_Bool
matchIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const throw( );
Match against a substring appearing in this string, ignoring the case of ASCII letters.
bool
endsWithAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const;
Check whether this string ends with a given ASCII string.
bool
endsWithIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const;
Check whether this string ends with a given ASCII string, ignoring the case of ASCII letters.
sal_Int32
hashCode( ) const throw( );
Returns a hashcode for this string.
sal_Int32
indexOf( sal_Unicode 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_Unicode 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_Unicode ch, sal_Int32 fromIndex ) const throw( );
sal_Int32
indexOf( const OUString & 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
indexOfAsciiL( const char * str, sal_Int32 len, sal_Int32 fromIndex = 0 ) const throw( );
Returns the index within this string of the first occurrence of the specified ASCII substring, starting at the specified index.
sal_Int32
lastIndexOf( const OUString & 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 OUString & str, sal_Int32 fromIndex ) const throw( );
sal_Int32
lastIndexOfAsciiL( const char * str, sal_Int32 len ) const throw( );
Returns the index within this string of the last occurrence of the specified ASCII substring.
OUString
copy( sal_Int32 beginIndex ) const throw( );
Returns a new string that is a substring of this string.
OUString
copy( sal_Int32 beginIndex, sal_Int32 count ) const throw( );
Returns a new string that is a substring of this string.
OUString
concat( const OUString & str ) const throw( );
Concatenates the specified string to the end of this string.
OUString
replaceAt( sal_Int32 index, sal_Int32 count, const OUString & newStr ) const throw( );
Returns a new string resulting from replacing n = count characters from position index in this string with newStr.
OUString
replace( sal_Unicode oldChar, sal_Unicode newChar ) const throw( );
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
OUString
toAsciiLowerCase( ) const throw( );
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-122).
OUString
toAsciiUpperCase( ) const throw( );
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-90).
OUString
trim( ) const throw( );
Returns a new string resulting from removing white space from both ends of the string.
OUString
getToken( sal_Int32 token, sal_Unicode 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_Unicode
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.
OUString
intern( ) const;
Return a canonical representation for a string.
bool
convertToString( OString * pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags ) const;
Converts to an OString, signalling failure.
sal_uInt32
iterateCodePoints( sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1 ) const;
Iterate through this string based on code points instead of UTF-16 code units.

Static Methods

static const OUString &
unacquired( rtl_uString * const * ppHandle );
static OUString
intern( const sal_Char * value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS, sal_uInt32 * pInfo = NULL );
Return a canonical representation for a converted string.
static OUString
valueOf( sal_Bool b ) throw( );
Returns the string representation of the sal_Bool argument.
static OUString
valueOf( sal_Unicode c ) throw( );
Returns the string representation of the char argument.
static OUString
valueOf( sal_Int32 i, sal_Int16 radix = 10 ) throw( );
Returns the string representation of the int argument.
static OUString
valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) throw( );
Returns the string representation of the long argument.
static OUString
valueOf( float f ) throw( );
Returns the string representation of the float argument.
static OUString
valueOf( double d ) throw( );
Returns the string representation of the double argument.
static OUString
createFromAscii( const sal_Char * value ) throw( );
Returns a OUString copied without conversion from an ASCII character string.

Top of Page

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache and the Apache feather logo are trademarks of The Apache Software Foundation. OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.