osncore::UString Class Reference

class osncore::UString

Class encapsulates utf-8 encoded string. UString has a character based API thus e.g length will return number of charaters. Unicode operations for utf8 encoded string can be done using glib unicode manipulation functions and/or using non-member functions for UString type.

osncore.lib
Since
S60 5.0 Draft UString

Nested Classes and Structures

  • osncore::UString::InvalidUtf8
Public Member Functions
UString ()
UString (const Utf8 *)
UString (const Utf8 *, int)
UString ( Unicode )
UString (const UString &)
~UString ()
OSN_IMPORT void append (const UString &)
OSN_IMPORT void append (const Utf8 *)
OSN_IMPORT int compare (const UString &)
OSN_IMPORT int compare (const Utf8 *)
OSN_IMPORT int compareC (const UString &)
OSN_IMPORT int compareC (const Utf8 *)
OSN_IMPORT void erase (long, long)
OSN_IMPORT long getByteLength ()
OSN_IMPORT long getCharLength ()
OSN_IMPORT const Utf8 * getUtf8 ()
OSN_IMPORT void insert (long, const Utf8 *)
OSN_IMPORT void insert (long, const Utf8 *, long)
OSN_IMPORT bool isEmpty ()
OSN_IMPORT bool isNull ()
OSN_IMPORT UString & operator= (const UString &)
OSN_IMPORT UString & operator= (const Utf8 *)
OSN_IMPORT bool operator== (const UString &)
OSN_IMPORT bool operator== (const Utf8 *)
OSN_IMPORT Unicode operator[] (long)
OSN_IMPORT void replace (long, const Utf8 *)
OSN_IMPORT void replace (long, const Utf8 *, long)
Private Attributes
auto_ptr < UStringImpl > mImpl

Constructor & Destructor Documentation

UString()

OSN_IMPORT UString ( )

Default constructor.

UString(const Utf8 *)

OSN_IMPORT UString ( const Utf8 * aStr ) [explicit]

Construct a UString as a copy of given null terminated string.

Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

const Utf8 * aStr Utf-8 encoded string

UString(const Utf8 *, int)

OSN_IMPORT UString ( const Utf8 * aStr,
int aByteCount
) [explicit]

Construct a UString as a copy of given string with byte length of the source buffer. Because a length is provided, source doesn't need to be null terminated.

Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

const Utf8 * aStr Utf-8 encoded string
int aByteCount Byte count of Utf-8 encoded string

UString(Unicode)

OSN_IMPORT UString ( Unicode aCodePoint ) [explicit]
Construct a UString from unicode code point. If Unicode is invalid,
Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

Unicode aCodePoint Unicode code point

UString(const UString &)

OSN_IMPORT UString ( const UString & aUString )
UString copy constructor
Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

const UString & aUString Copy source

~UString()

OSN_IMPORT ~UString ( ) [virtual]

Destructor.

Member Functions Documentation

append(const UString &)

OSN_IMPORT void append ( const UString & aUString )

Adds a string onto the end of string, expanding it if necessary.

Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

const UString & aUString String object to append

append(const Utf8 *)

OSN_IMPORT void append ( const Utf8 * aStr )

Adds a string onto the end of string, expanding it if necessary.

Since
S60 5.0
Exceptions
std::bad_alloc

Parameters

const Utf8 * aStr String to append

compare(const UString &)

OSN_IMPORT int compare ( const UString & aUString ) const

Compares two strings using strcmp() . Note that this is not linguistic comparison nor case insensitive.

Since
S60 5.0

Parameters

const UString & aUString UString object to compare

compare(const Utf8 *)

OSN_IMPORT int compare ( const Utf8 * aStr ) const

Compares two strings using strcmp() . Note that this is not linguistic comparison nor case insensitive.

Since
S60 5.0

Parameters

const Utf8 * aStr String to compare

compareC(const UString &)

OSN_IMPORT int compareC ( const UString & aUString ) const

Compares two strings for ordering using the linguistically correct rules for the current locale. When sorting a large number of strings, it will be significantly faster to obtain collation keys with g_utf8_collate_key() from libglib and compare the keys with strcmp() when sorting instead of sorting the original strings.

Since
S60 5.0

Parameters

const UString & aUString UString object to compare

compareC(const Utf8 *)

OSN_IMPORT int compareC ( const Utf8 * aStr ) const

Compares two strings for ordering using the linguistically correct rules for the current locale. When sorting a large number of strings, it will be significantly faster to obtain collation keys with g_utf8_collate_key() from libglib and compare the keys with strcmp() when sorting instead of sorting the original strings. If aStr is invalid utf8, UString::InvalidUtf8 exception is thrown.

Since
S60 5.0

Parameters

const Utf8 * aStr String to compare

erase(long, long)

OSN_IMPORT void erase ( long aPos,
long aCharCount
)

Erase a substring

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The character position to start erasing from
long aCharCount number of characters to erase.

getByteLength()

OSN_IMPORT long getByteLength ( ) const

Returns the length of the string in bytes

Since
S60 5.0

getCharLength()

OSN_IMPORT long getCharLength ( ) const

Returns the length of the string in characters.

Since
S60 5.0

getUtf8()

OSN_IMPORT const Utf8 * getUtf8 ( ) const

Returns utf8 type string

Since
S60 5.0

insert(long, const Utf8 *)

OSN_IMPORT void insert ( long aPos,
const Utf8 * aStr
)

Inserts aStr into string, expanding it if necessary. If aPos is -1, bytes are inserted at the end of the string.

Since
S60 5.0
Exceptions
std::bad_alloc

std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The character position to insert the copy of the string
const Utf8 * aStr The string to insert

insert(long, const Utf8 *, long)

OSN_IMPORT void insert ( long aPos,
const Utf8 * aStr,
long aCharCount
)

Inserts aStr into string, expanding it if necessary. Because length is provided, aStr may contain embedded nulls and need not be null terminated. If aPos is -1, bytes are inserted at the end of the string.

Since
S60 5.0
Exceptions
std::bad_alloc

std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The character position to insert the copy of the string
const Utf8 * aStr The string to insert
long aCharCount Character count.

isEmpty()

OSN_IMPORT bool isEmpty ( ) const

Checks whether string is empty.

Since
S60 5.0

isNull()

OSN_IMPORT bool isNull ( ) const

Checks whether string is null.

Since
S60 5.0

operator=(const UString &)

OSN_IMPORT UString & operator= ( const UString & aRhs )

Copy assignment

Since
S60 5.0

Parameters

const UString & aRhs Assignment source

operator=(const Utf8 *)

OSN_IMPORT UString & operator= ( const Utf8 * aRhs )

Copy assignment

Since
S60 5.0

Parameters

const Utf8 * aRhs Assignment source

operator==(const UString &)

OSN_IMPORT bool operator== ( const UString & aRhs ) const

Compares two strings using strcmp()

Since
S60 5.0

Parameters

const UString & aRhs UString object to compare

operator==(const Utf8 *)

OSN_IMPORT bool operator== ( const Utf8 * aRhs ) const

Compares two strings using strcmp()

Since
S60 5.0

Parameters

const Utf8 * aRhs String to compare

operator[](long)

OSN_IMPORT Unicode operator[] ( long aPos )

Returns unicode at given position in string

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The requested position

replace(long, const Utf8 *)

OSN_IMPORT void replace ( long aPos,
const Utf8 * aStr
)

Replace a substring with a given string, expanding it if necessary

Since
S60 5.0
Exceptions
std::bad_alloc

std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The charater position to replace the string
const Utf8 * aStr The string to insert

replace(long, const Utf8 *, long)

OSN_IMPORT void replace ( long aPos,
const Utf8 * aStr,
long aCharCount
)

Replace a substring with a given string, expanding it if necessary. Because length is provided, aStr may contain embedded nulls and need not be null terminated. If aLength is < 0, length is assumed to be aStr's length.

Since
S60 5.0
Exceptions
std::bad_alloc

std:out_of_range

is thrown if given position is invalid

Parameters

long aPos The character position to replace the string
const Utf8 * aStr The string to insert
long aCharCount Character count.

Member Data Documentation

auto_ptr< UStringImpl > mImpl

auto_ptr < UStringImpl > mImpl [private]

Implementation.