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

Public Member Functions
UString()
UString(const Utf8 *)
UString(const Utf8 *, int)
UString(Unicode)
UString(const UString &)
~UString()
OSN_IMPORT voidappend(const UString &)
OSN_IMPORT voidappend(const Utf8 *)
OSN_IMPORT intcompare(const UString &)
OSN_IMPORT intcompare(const Utf8 *)
OSN_IMPORT intcompareC(const UString &)
OSN_IMPORT intcompareC(const Utf8 *)
OSN_IMPORT voiderase(long, long)
OSN_IMPORT longgetByteLength()
OSN_IMPORT longgetCharLength()
OSN_IMPORT const Utf8 *getUtf8()
OSN_IMPORT voidinsert(long, const Utf8 *)
OSN_IMPORT voidinsert(long, const Utf8 *, long)
OSN_IMPORT boolisEmpty()
OSN_IMPORT boolisNull()
OSN_IMPORT UString &operator=(const UString &)
OSN_IMPORT UString &operator=(const Utf8 *)
OSN_IMPORT booloperator==(const UString &)
OSN_IMPORT booloperator==(const Utf8 *)
OSN_IMPORT Unicodeoperator[](long)
OSN_IMPORT voidreplace(long, const Utf8 *)
OSN_IMPORT voidreplace(long, const Utf8 *, long)
Private Attributes
auto_ptr< UStringImpl >mImpl

Constructor & Destructor Documentation

UString()

OSN_IMPORTUString()

Default constructor.

UString(const Utf8 *)

OSN_IMPORTUString(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 * aStrUtf-8 encoded string

UString(const Utf8 *, int)

OSN_IMPORTUString(const Utf8 *aStr,
intaByteCount
)[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 * aStrUtf-8 encoded string
int aByteCountByte count of Utf-8 encoded string

UString(Unicode)

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

Parameters

Unicode aCodePointUnicode code point

UString(const UString &)

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

Parameters

const UString & aUStringCopy source

~UString()

OSN_IMPORT~UString()[virtual]

Destructor.

Member Functions Documentation

append(const UString &)

OSN_IMPORT voidappend(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 & aUStringString object to append

append(const Utf8 *)

OSN_IMPORT voidappend(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 * aStrString to append

compare(const UString &)

OSN_IMPORT intcompare(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 & aUStringUString object to compare

compare(const Utf8 *)

OSN_IMPORT intcompare(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 * aStrString to compare

compareC(const UString &)

OSN_IMPORT intcompareC(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 & aUStringUString object to compare

compareC(const Utf8 *)

OSN_IMPORT intcompareC(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 * aStrString to compare

erase(long, long)

OSN_IMPORT voiderase(longaPos,
longaCharCount
)

Erase a substring

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given position is invalid

Parameters

long aPosThe character position to start erasing from
long aCharCountnumber of characters to erase.

getByteLength()

OSN_IMPORT longgetByteLength()const

Returns the length of the string in bytes

Since
S60 5.0

getCharLength()

OSN_IMPORT longgetCharLength()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 voidinsert(longaPos,
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 aPosThe character position to insert the copy of the string
const Utf8 * aStrThe string to insert

insert(long, const Utf8 *, long)

OSN_IMPORT voidinsert(longaPos,
const Utf8 *aStr,
longaCharCount
)

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 aPosThe character position to insert the copy of the string
const Utf8 * aStrThe string to insert
long aCharCountCharacter count.

isEmpty()

OSN_IMPORT boolisEmpty()const

Checks whether string is empty.

Since
S60 5.0

isNull()

OSN_IMPORT boolisNull()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 & aRhsAssignment source

operator=(const Utf8 *)

OSN_IMPORT UString &operator=(const Utf8 *aRhs)

Copy assignment

Since
S60 5.0

Parameters

const Utf8 * aRhsAssignment source

operator==(const UString &)

OSN_IMPORT booloperator==(const UString &aRhs)const

Compares two strings using strcmp()

Since
S60 5.0

Parameters

const UString & aRhsUString object to compare

operator==(const Utf8 *)

OSN_IMPORT booloperator==(const Utf8 *aRhs)const

Compares two strings using strcmp()

Since
S60 5.0

Parameters

const Utf8 * aRhsString to compare

operator[](long)

OSN_IMPORT Unicodeoperator[](longaPos)

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 aPosThe requested position

replace(long, const Utf8 *)

OSN_IMPORT voidreplace(longaPos,
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 aPosThe charater position to replace the string
const Utf8 * aStrThe string to insert

replace(long, const Utf8 *, long)

OSN_IMPORT voidreplace(longaPos,
const Utf8 *aStr,
longaCharCount
)

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 aPosThe character position to replace the string
const Utf8 * aStrThe string to insert
long aCharCountCharacter count.

Member Data Documentation

auto_ptr< UStringImpl > mImpl

auto_ptr< UStringImpl >mImpl[private]

Implementation.