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 ()
void append (const UStringImpl &)
void append (const Utf8 *)
long bytes ()
int compare (const UStringImpl &)
int compare (const Utf8 *)
int compareC (const UStringImpl &)
int compareC (const Utf8 *)
bool empty ()
void erase (long, long)
void insert (long, const Utf8 *)
void insert (long, const Utf8 *, long)
long length ()
bool null ()
Unicode operator[] (long)
void replace (long, const Utf8 *)
void replace (long, const Utf8 *, long)
const Utf8 * utf8 ()
Private Member Functions
void appendImpl (const char *, unsigned int)
void checkBuffer (unsigned int)
void eraseImpl (unsigned int, unsigned int)
void initialize (const Utf8 *)
void insertImpl (unsigned int, const char *, unsigned int)
Private Attributes
gsize allocated_len
gchar internalStr
bool isInHeap
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 * aStr Utf-8 encoded string

UStringImpl(const Utf8 *, int)

UStringImpl ( const Utf8 * aStr,
int aLen
) [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 * aStr Utf-8 encoded string
int aLen

UStringImpl(Unicode)

UStringImpl ( Unicode aCodePoint ) [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 aCodePoint Unicode 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 &)

void append ( const UStringImpl & aUStringImpl )

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

Since
S60 5.0

Parameters

const UStringImpl & aUStringImpl String object to append

append(const Utf8 *)

void append ( const Utf8 * aStr )

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

Since
S60 5.0

Parameters

const Utf8 * aStr String to append

appendImpl(const char *, unsigned int)

void appendImpl ( const char * aStr,
unsigned int aLength
) [private]
Implements the append functionality
Since
S60 5.0

Parameters

const char * aStr The string to append
unsigned int aLength The amount of characters to append

bytes()

long bytes ( ) const

Returns the length of the string in bytes

Since
S60 5.0

checkBuffer(unsigned int)

void checkBuffer ( unsigned int aLength ) [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 aLength length of bytes to allocate

compare(const UStringImpl &)

int compare ( 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 & aUStringImpl UStringImpl object to compare

compare(const Utf8 *)

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

int compareC ( 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 & aUStringImpl UStringImpl object to compare

compareC(const Utf8 *)

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

empty()

bool empty ( ) const

Checks whether string is empty.

Since
S60 5.0

erase(long, long)

void erase ( long aPosOffset,
long aLength
)

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)

void eraseImpl ( unsigned int aIndex,
unsigned int aLength
) [private]
Implements the erase functionality
Since
S60 5.0
Exceptions
std:out_of_range

is thrown if given index is invalid

Parameters

unsigned int aIndex The character position to start erasing from
unsigned int aLength The amount of characters to erase

initialize(const Utf8 *)

void initialize ( 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 * aStr The string used for initialising

insert(long, const Utf8 *)

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

is thrown if given position is invalid

std:bad_alloc

is thrown if string cannot be allocated from heap

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)

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

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 aPos The character position to insert the copy of the string
const Utf8 * aStr The string to insert
long aLength

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

void insertImpl ( unsigned int aIndex,
const char * aInsertChars,
unsigned int aInsertLength
) [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 aIndex The character position to insert the copy of the string
const char * aInsertChars The string to insert
unsigned int aInsertLength The amount of characters to insert

length()

long length ( ) const

Returns the length of the string in characters.

Since
S60 5.0

null()

bool null ( ) const

Checks whether string is null.

Since
S60 5.0

operator[](long)

Unicode operator[] ( long aIndex )

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 *)

void replace ( long aPos,
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 aPos The charater position to replace the string
const Utf8 * aStr The string to insert

replace(long, const Utf8 *, long)

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

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 aPos The character position to replace the string
const Utf8 * aStr The 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

bool isInHeap [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