osncore::UStringImpl Class Reference

class osncore::UStringImpl
Glib string wrapper. ustring.h for description of ustring osncore.lib
Since
S60 5.0
Public Member Functions
UStringImpl()
UStringImpl(const Utf8 *)
UStringImpl(const Utf8 *, int)
UStringImpl(Unicode)
UStringImpl(const UStringImpl &)
~UStringImpl()
voidappend(const UStringImpl &)
voidappend(const Utf8 *)
longbytes()
intcompare(const UStringImpl &)
intcompare(const Utf8 *)
intcompareC(const UStringImpl &)
intcompareC(const Utf8 *)
boolempty()
voiderase(long, long)
voidinsert(long, const Utf8 *)
voidinsert(long, const Utf8 *, long)
longlength()
boolnull()
Unicode operator[](long)
voidreplace(long, const Utf8 *)
voidreplace(long, const Utf8 *, long)
const Utf8 *utf8()
Private Member Functions
voidappendImpl(const char *, unsigned int)
voidcheckBuffer(unsigned int)
voideraseImpl(unsigned int, unsigned int)
voidinitialize(const Utf8 *)
voidinsertImpl(unsigned int, const char *, unsigned int)
Private Attributes
gsize allocated_len
gchar internalStr
boolisInHeap
gsize len
gchar *str

Constructor & Destructor Documentation

UStringImpl()

UStringImpl()

Default constructor.

UStringImpl(const Utf8 *)

UStringImpl(const Utf8 *aStr)[explicit]

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

Since
S60 5.0
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

const Utf8 * aStrUtf-8 encoded string

UStringImpl(const Utf8 *, int)

UStringImpl(const Utf8 *aStr,
intaLen
)[explicit]

Construct a string 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

is thrown if string cannot be allocated from heap

Parameters

const Utf8 * aStrUtf-8 encoded string
int aLen

UStringImpl(Unicode)

UStringImpl(UnicodeaCodePoint)[explicit]
Construct a string from unicode code point. If Unicode is invalid,
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Since
S60 5.0

Parameters

Unicode aCodePointUnicode code point

UStringImpl(const UStringImpl &)

UStringImpl(const UStringImpl &aUStringImpl)
UStringImpl copy constructor
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Since
S60 5.0

Parameters

const UStringImpl & aUStringImpl

~UStringImpl()

~UStringImpl()

Member Functions Documentation

append(const UStringImpl &)

voidappend(const UStringImpl &aUStringImpl)

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

Since
S60 5.0

Parameters

const UStringImpl & aUStringImplString object to append

append(const Utf8 *)

voidappend(const Utf8 *aStr)

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

Since
S60 5.0

Parameters

const Utf8 * aStrString to append

appendImpl(const char *, unsigned int)

voidappendImpl(const char *aStr,
unsigned intaLength
)[private]
Implements the append functionality
Since
S60 5.0

Parameters

const char * aStrThe string to append
unsigned int aLengthThe amount of characters to append

bytes()

longbytes()const

Returns the length of the string in bytes

Since
S60 5.0

checkBuffer(unsigned int)

voidcheckBuffer(unsigned intaLength)[private]
Allocates memory from heap if needed for internal string, throws if allocation fail
Since
S60 5.0
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

unsigned int aLengthlength of bytes to allocate

compare(const UStringImpl &)

intcompare(const UStringImpl &aUStringImpl)const

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

Since
S60 5.0

Parameters

const UStringImpl & aUStringImplUStringImpl object to compare

compare(const Utf8 *)

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 UStringImpl &)

intcompareC(const UStringImpl &aUStringImpl)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 UStringImpl & aUStringImplUStringImpl object to compare

compareC(const Utf8 *)

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

empty()

boolempty()const

Checks whether string is empty.

Since
S60 5.0

erase(long, long)

voiderase(longaPosOffset,
longaLength
)

Erase a substring

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given position is invalid

Parameters

long aPosOffset
long aLength

eraseImpl(unsigned int, unsigned int)

voideraseImpl(unsigned intaIndex,
unsigned intaLength
)[private]
Implements the erase functionality
Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given index is invalid

Parameters

unsigned int aIndexThe character position to start erasing from
unsigned int aLengthThe amount of characters to erase

initialize(const Utf8 *)

voidinitialize(const Utf8 *aStr)[private]
Initialises internal string
Since
S60 5.0
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

const Utf8 * aStrThe string used for initialising

insert(long, const Utf8 *)

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

is thrown if given position is invalid

std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

long aPosThe character position to insert the copy of the string
const Utf8 * aStrThe string to insert

insert(long, const Utf8 *, long)

voidinsert(longaPos,
const Utf8 *aStr,
longaLength
)

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

is thrown if given position is invalid

std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

long aPosThe character position to insert the copy of the string
const Utf8 * aStrThe string to insert
long aLength

insertImpl(unsigned int, const char *, unsigned int)

voidinsertImpl(unsigned intaIndex,
const char *aInsertChars,
unsigned intaInsertLength
)[private]
Implements the insertion functionality
Since
S60 5.0
Exceptions
std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

unsigned int aIndexThe character position to insert the copy of the string
const char * aInsertCharsThe string to insert
unsigned int aInsertLengthThe amount of characters to insert

length()

longlength()const

Returns the length of the string in characters.

Since
S60 5.0

null()

boolnull()const

Checks whether string is null.

Since
S60 5.0

operator[](long)

Unicode operator[](longaIndex)

Returns unicode at given position in string

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if requested index is invalid

Parameters

long aIndex

replace(long, const Utf8 *)

voidreplace(longaPos,
const Utf8 *aStr
)

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

Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given position is invalid

std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

long aPosThe charater position to replace the string
const Utf8 * aStrThe string to insert

replace(long, const Utf8 *, long)

voidreplace(longaPos,
const Utf8 *aStr,
longaLength
)

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

is thrown if given position is invalid

std:bad_alloc

is thrown if string cannot be allocated from heap

Parameters

long aPosThe character position to replace the string
const Utf8 * aStrThe string to insert
long aLength

utf8()

const Utf8 *utf8()const

Returns utf8 type string

Since
S60 5.0

Member Data Documentation

gsize allocated_len

gsize allocated_len[private]

length of allocated bytes

gchar internalStr

gchar internalStr[private]

Internal buffer, allocated from stack. Short strings are allocated from stack for performance reason,

bool isInHeap

boolisInHeap[private]

Identifies if string is allocated from heap or not

gsize len

gsize len[private]

length of string

gchar * str

gchar *str[private]

Internal buffer, allocated from heap. Long strings are allocated from heap