TXmlEngConstString Class Reference

#include <xml/utils/xmlengxestrings.h>

Link against: xmlengineutils.lib

class TXmlEngConstString
Protected Attributes
char *iString
Public Member Functions
TXmlEngConstString()
TXmlEngConstString(const char *)
IMPORT_C HBufC *AllocL()
IMPORT_C HBufC *AllocLC()
IMPORT_C TIntCompare(TXmlEngConstString)
IMPORT_C char *CopyL()
const char *Cstring()
const char *CstringDef(const char *)
TBool Equals(TXmlEngConstString)
TBool IsNull()
IMPORT_C TUintLength()
TBool NotNull()
TPtrC8 PtrC8()
IMPORT_C TUintSize()
Protected Member Functions
voidSet(char *)

Detailed Description

Implements a constant string used within libxml2-based API's.

TXmlEngConstString contains a pointer to a zero-terminated UTF-8 string. The contents of the string is not supposed to be changed. From this point of view TXmlEngConstString instances are close to the concept of immutable strings.

Ownership of the string is not defined for TXmlEngConstString. Thus, in different contexts (APIs), different string-handling policies may be applied. For instance, in XML Engine SAX API all reported via callbacks strings of TXmlEngConstString type are assumed owned by the parser.

TXmlEngConstString is a base class for other specialized string classes in XML Engine APIs.

Member Attribute Documentation

iString

char *iString[protected]

String value

Constructor & Destructor Documentation

TXmlEngConstString ( )

TXmlEngConstString()[inline]

Default constructor

TXmlEngConstString ( const char * )

TXmlEngConstString(const char *aString)[inline]

Constructor

Parameters
aStringThe string for initialization. Ownership is not transferred and the string must stay in scope for the lifetime of this object.

Member Function Documentation

AllocL ( )

IMPORT_C HBufC *AllocL()const

Allocates a HBufC from the string contents. Ownership is transferred to the caller.

Typical use:
       ...
       HBufC* attrValue = attr.Value().AllocL();
       ...

See also: AllocLC()

Allocates UTF-16 heap descriptor from the TDOMString contents

Typical use:
    ...
    HBufC* attrValue = attr.Value().AllocL();
    ...

AllocLC() does the same, but returned HBufC* is already on the cleanup stack after a call to this method.

Leave Codes
KErrNoMemoryMemory allocation failure
KUriUtilsCannotConvertString cannot be converted

AllocLC ( )

IMPORT_C HBufC *AllocLC()const

Allocates a HBufC from the string contents and pushes the descriptor to cleanup stack. Ownership is transferred to the caller.

Typical use:
       ...
       HBufC* attrValue = attr.Value().AllocLC();
       ...

See also: AllocL()

Allocates UTF-16 heap descriptor from the TXmlEngConstString contents and pushes the descriptor to cleanup stack.

Typical use:
    ...
    HBufC* attrValue = attr.Value().AllocLC();
    ...
Leave Codes
KErrNoMemoryMemory allocation failure
KUriUtilsCannotConvertString cannot be converted

Compare ( TXmlEngConstString )

IMPORT_C TIntCompare(TXmlEngConstStringaString)const

Compares with another string. NULL and "" are considered equal.

Parameters
aStringThe string to compare
Return Value
0 if equal, -1 otherwise

CopyL ( )

IMPORT_C char *CopyL()const

Creates a new copy of the string contents. Ownership for the new string is transferred to the caller.

Return Value
A c string copy of the string contents
Leave Codes
KErrNoMemoryMemory allocation failure

Cstring ( )

const char *Cstring()const [inline]

Gets a c string

Return Value
The string as a C string or NULL if null

CstringDef ( const char * )

const char *CstringDef(const char *aDefaultValue)const [inline]

Gets a c string or if NULL, return a default value.

Parameters
aDefaultValuedefault value
Return Value
If not NULL, the c string, otherwise aDefaultValue

Equals ( TXmlEngConstString )

TBool Equals(TXmlEngConstStringaString)const [inline]

Compares with another string. NULL and "" are considered equal.

Parameters
aStringThe string to compare
Return Value
ETrue if equal, EFalse otherwise

IsNull ( )

TBool IsNull()const [inline]

Check if the string is NULL

Return Value
ETrue if the string is null, EFalse otherwise

Length ( )

IMPORT_C TUintLength()const

Get the length of the string. For non-ASCII strings, Size() != Length() due to the UTF-8 encoding used for non-ASCII characters.

Return Value
The number of characters in the string

NotNull ( )

TBool NotNull()const [inline]

Check if the string is not NULL

Return Value
ETrue if the string is not null, EFalse otherwise

PtrC8 ( )

TPtrC8 PtrC8()const [inline]

Get a TPtrC8 that contains the string

Return Value
A point descriptor that holds the string

Set ( char * )

voidSet(char *aString)[protected, inline]

Set a new string value. The old string is not freed. Ownership is not transferred.

Parameters
aStringThe new value

Size ( )

IMPORT_C TUintSize()const

Returns the size of the string in bytes

Return Value
The size